Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve modularization #852

Merged
merged 19 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
import java.util.function.Supplier;
import org.apache.baremaps.cli.Options;
import org.apache.baremaps.config.ConfigReader;
import org.apache.baremaps.maplibre.style.Style;
import org.apache.baremaps.maplibre.tileset.Tileset;
import org.apache.baremaps.server.ChangeResource;
import org.apache.baremaps.server.StyleResource;
import org.apache.baremaps.server.TileResource;
import org.apache.baremaps.server.TilesetResource;
import org.apache.baremaps.tilestore.TileStore;
import org.apache.baremaps.tilestore.postgres.PostgresTileStore;
import org.apache.baremaps.utils.PostgresUtils;
import org.apache.baremaps.vectortile.style.Style;
import org.apache.baremaps.vectortile.tileset.Tileset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import java.util.Map;
import java.util.concurrent.Callable;
import org.apache.baremaps.cli.Options;
import org.apache.baremaps.vectortile.style.Style;
import org.apache.baremaps.vectortile.style.StyleSource;
import org.apache.baremaps.vectortile.tileset.Tileset;
import org.apache.baremaps.maplibre.style.Style;
import org.apache.baremaps.maplibre.style.StyleSource;
import org.apache.baremaps.maplibre.tileset.Tileset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
import java.util.function.Supplier;
import org.apache.baremaps.cli.Options;
import org.apache.baremaps.config.ConfigReader;
import org.apache.baremaps.maplibre.style.Style;
import org.apache.baremaps.maplibre.tilejson.TileJSON;
import org.apache.baremaps.server.*;
import org.apache.baremaps.tilestore.TileCache;
import org.apache.baremaps.tilestore.TileStore;
import org.apache.baremaps.tilestore.mbtiles.MBTilesStore;
import org.apache.baremaps.utils.SqliteUtils;
import org.apache.baremaps.vectortile.style.Style;
import org.apache.baremaps.vectortile.tilejson.TileJSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import java.util.function.Supplier;
import org.apache.baremaps.cli.Options;
import org.apache.baremaps.config.ConfigReader;
import org.apache.baremaps.maplibre.style.Style;
import org.apache.baremaps.maplibre.tilejson.TileJSON;
import org.apache.baremaps.maplibre.tileset.Tileset;
import org.apache.baremaps.server.SearchResource;
import org.apache.baremaps.server.StyleResource;
import org.apache.baremaps.server.TileJSONResource;
Expand All @@ -41,9 +44,6 @@
import org.apache.baremaps.tilestore.TileStore;
import org.apache.baremaps.tilestore.postgres.PostgresTileStore;
import org.apache.baremaps.utils.PostgresUtils;
import org.apache.baremaps.vectortile.style.Style;
import org.apache.baremaps.vectortile.tilejson.TileJSON;
import org.apache.baremaps.vectortile.tileset.Tileset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Command;
Expand Down
49 changes: 18 additions & 31 deletions baremaps-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,24 @@ limitations under the License.
<artifactId>ipresource</artifactId>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<groupId>org.apache.baremaps</groupId>
<artifactId>baremaps-data</artifactId>
</dependency>
<dependency>
<groupId>org.apache.baremaps</groupId>
<artifactId>baremaps-maplibre</artifactId>
</dependency>
<dependency>
<groupId>org.apache.baremaps</groupId>
<artifactId>baremaps-openstreetmap</artifactId>
</dependency>
<dependency>
<groupId>org.apache.baremaps</groupId>
<artifactId>baremaps-pmtiles</artifactId>
</dependency>
<dependency>
<groupId>org.apache.baremaps</groupId>
<artifactId>baremaps-testing</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -131,33 +147,4 @@ limitations under the License.
<artifactId>sqlite-jdbc</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${version.plugin.protobuf-maven-plugin}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${version.lib.protobuf}:exe:${os.detected.classifier}</protocArtifact>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>${version.plugin.os-maven-plugin}</version>
</extension>
</extensions>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,28 @@
* limitations under the License.
*/

package org.apache.baremaps.openstreetmap;
package org.apache.baremaps.database;

import static org.apache.baremaps.stream.ConsumerUtils.consumeThenReturn;
import static org.apache.baremaps.openstreetmap.stream.ConsumerUtils.consumeThenReturn;

import java.io.BufferedInputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.List;
import java.util.Optional;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import java.util.zip.GZIPInputStream;
import org.apache.baremaps.database.collection.DataMap;
import org.apache.baremaps.database.postgres.HeaderRepository;
import org.apache.baremaps.database.postgres.Repository;
import org.apache.baremaps.openstreetmap.function.EntityGeometryBuilder;
import org.apache.baremaps.openstreetmap.function.EntityToGeometryMapper;
import org.apache.baremaps.openstreetmap.function.ProjectionTransformer;
import org.apache.baremaps.openstreetmap.model.*;
import org.apache.baremaps.openstreetmap.repository.HeaderRepository;
import org.apache.baremaps.openstreetmap.repository.Repository;
import org.apache.baremaps.openstreetmap.stream.StreamException;
import org.apache.baremaps.openstreetmap.xml.XmlChangeReader;
import org.apache.baremaps.stream.StreamException;
import org.apache.baremaps.tilestore.TileCoord;
import org.apache.baremaps.utils.ProjectionTransformer;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.slf4j.Logger;
Expand All @@ -50,17 +46,18 @@ public class DiffService implements Callable<List<TileCoord>> {

private static final Logger logger = LoggerFactory.getLogger(DiffService.class);

private final DataMap<Long, Coordinate> coordinateMap;
private final DataMap<Long, List<Long>> referenceMap;
private final Map<Long, Coordinate> coordinateMap;
private final Map<Long, List<Long>> referenceMap;
private final HeaderRepository headerRepository;
private final Repository<Long, Node> nodeRepository;
private final Repository<Long, Way> wayRepository;
private final Repository<Long, Relation> relationRepository;
private final int srid;
private final int zoom;

public DiffService(DataMap<Long, Coordinate> coordinateMap,
DataMap<Long, List<Long>> referenceMap,
public DiffService(
Map<Long, Coordinate> coordinateMap,
Map<Long, List<Long>> referenceMap,
HeaderRepository headerRepository, Repository<Long, Node> nodeRepository,
Repository<Long, Way> wayRepository, Repository<Long, Relation> relationRepository, int srid,
int zoom) {
Expand All @@ -86,7 +83,7 @@ public List<TileCoord> call() throws Exception {
var projectionTransformer = new ProjectionTransformer(srid, 4326);
try (var changeInputStream =
new GZIPInputStream(new BufferedInputStream(changeUrl.openStream()))) {
return new XmlChangeReader().stream(changeInputStream).flatMap(this::geometriesForChange)
return new XmlChangeReader().read(changeInputStream).flatMap(this::geometriesForChange)
.map(projectionTransformer::transform).flatMap(this::tilesForGeometry).distinct()
.toList();
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.baremaps.postgres.copy;
package org.apache.baremaps.database.copy;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.baremaps.postgres.copy;
package org.apache.baremaps.database.copy;

import static org.locationtech.jts.io.WKBConstants.wkbNDR;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
* limitations under the License.
*/

package org.apache.baremaps.openstreetmap.repository;
package org.apache.baremaps.database.function;



import java.util.function.Consumer;
import org.apache.baremaps.database.postgres.Repository;
import org.apache.baremaps.openstreetmap.model.*;
import org.apache.baremaps.stream.StreamException;
import org.apache.baremaps.openstreetmap.stream.StreamException;

/** A consumer for importing OpenStreetMap blocks in a database. */
public class BlockImporter implements Consumer<Block> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* limitations under the License.
*/

package org.apache.baremaps.openstreetmap.repository;
package org.apache.baremaps.database.function;


import java.util.function.Consumer;
import org.apache.baremaps.database.postgres.Repository;
import org.apache.baremaps.database.postgres.RepositoryException;
import org.apache.baremaps.openstreetmap.model.Change;
import org.apache.baremaps.openstreetmap.model.Element;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* limitations under the License.
*/

package org.apache.baremaps.openstreetmap.repository;
package org.apache.baremaps.database.function;


import java.util.function.Consumer;
import org.apache.baremaps.database.postgres.Repository;
import org.apache.baremaps.database.postgres.RepositoryException;
import org.apache.baremaps.openstreetmap.model.Change;
import org.apache.baremaps.openstreetmap.model.Node;
import org.apache.baremaps.openstreetmap.model.Relation;
Expand Down
Loading
Loading