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

Set feature IDs in boundary and agg_stop features. #148

Merged
merged 3 commits into from
Jan 15, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/org/openmaptiles/layers/Boundary.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public void processAllOsm(SourceFeature feature, FeatureCollector features) {
// save for later
try {
CountryBoundaryComponent component = new CountryBoundaryComponent(
feature.id(),
minAdminLevel,
disputed,
maritime,
Expand Down Expand Up @@ -323,7 +324,7 @@ public void finish(String sourceName, FeatureCollector.Factory featureCollectors
if (merged instanceof LineString lineString) {
BorderingRegions borderingRegions = getBorderingRegions(countryBoundaries, key.regions, lineString);

var features = featureCollectors.get(SimpleFeature.fromWorldGeometry(lineString));
var features = featureCollectors.get(SimpleFeature.fromWorldGeometry(lineString, key.id));
var newFeature = features.line(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
.setAttr(Fields.ADMIN_LEVEL, key.adminLevel)
.setAttr(Fields.DISPUTED, key.disputed ? 1 : 0)
Expand Down Expand Up @@ -471,6 +472,7 @@ public long estimateMemoryUsageBytes() {
* Information to hold onto from processing a way in a boundary relation to determine the left/right region ID later.
*/
private record CountryBoundaryComponent(
long id,
int adminLevel,
boolean disputed,
boolean maritime,
Expand All @@ -482,7 +484,7 @@ private record CountryBoundaryComponent(
) {

CountryBoundaryComponent groupingKey() {
return new CountryBoundaryComponent(adminLevel, disputed, maritime, minzoom, null, regions, claimedBy, name);
return new CountryBoundaryComponent(id, adminLevel, disputed, maritime, minzoom, null, regions, claimedBy, name);
}
}
}
7 changes: 4 additions & 3 deletions src/main/java/org/openmaptiles/layers/Poi.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ public void process(Tables.OsmPoiPoint element, FeatureCollector features) {
private void processAggStop(Tables.OsmPoiPoint element, FeatureCollector.Factory featureCollectors,
Consumer<FeatureCollector.Feature> emit, Integer aggStop) {
try {
var features = featureCollectors.get(SimpleFeature.fromWorldGeometry(element.source().worldGeometry()));
var features =
featureCollectors.get(SimpleFeature.fromWorldGeometry(element.source().worldGeometry(), element.source().id()));
setupPoiFeature(element, features.point(LAYER_NAME), aggStop);
for (var feature : features) {
emit.accept(feature);
Expand Down Expand Up @@ -209,7 +210,6 @@ public void finish(String sourceName, FeatureCollector.Factory featureCollectors
processAggStop(aggStopSet.getFirst(), featureCollectors, emit, 1);
continue;
}

Tables.OsmPoiPoint nearest = null;
try {
// find most important stops based on subclass
Expand All @@ -228,7 +228,8 @@ public void finish(String sourceName, FeatureCollector.Factory featureCollectors
double minDistance = Double.MAX_VALUE;
for (var aggStop : topAggStops) {
double distance = aggStopCentroid.distance(aggStop.source().worldGeometry());
if (distance < minDistance) {
if (distance < minDistance || nearest == null ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

(distance == minDistance && aggStop.source().id() < nearest.source().id())) {
minDistance = distance;
nearest = aggStop;
}
Expand Down
Loading