Set feature IDs in boundary and agg_stop features. (#148)

This commit is contained in:
Michael Barry
2024-01-15 11:54:51 -05:00
committed by GitHub
parent 1e60f45639
commit f038d69af1
2 changed files with 8 additions and 5 deletions

View File

@@ -269,6 +269,7 @@ public class Boundary implements
// save for later // save for later
try { try {
CountryBoundaryComponent component = new CountryBoundaryComponent( CountryBoundaryComponent component = new CountryBoundaryComponent(
feature.id(),
minAdminLevel, minAdminLevel,
disputed, disputed,
maritime, maritime,
@@ -323,7 +324,7 @@ public class Boundary implements
if (merged instanceof LineString lineString) { if (merged instanceof LineString lineString) {
BorderingRegions borderingRegions = getBorderingRegions(countryBoundaries, key.regions, 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) var newFeature = features.line(LAYER_NAME).setBufferPixels(BUFFER_SIZE)
.setAttr(Fields.ADMIN_LEVEL, key.adminLevel) .setAttr(Fields.ADMIN_LEVEL, key.adminLevel)
.setAttr(Fields.DISPUTED, key.disputed ? 1 : 0) .setAttr(Fields.DISPUTED, key.disputed ? 1 : 0)
@@ -471,6 +472,7 @@ public class Boundary implements
* Information to hold onto from processing a way in a boundary relation to determine the left/right region ID later. * Information to hold onto from processing a way in a boundary relation to determine the left/right region ID later.
*/ */
private record CountryBoundaryComponent( private record CountryBoundaryComponent(
long id,
int adminLevel, int adminLevel,
boolean disputed, boolean disputed,
boolean maritime, boolean maritime,
@@ -482,7 +484,7 @@ public class Boundary implements
) { ) {
CountryBoundaryComponent groupingKey() { 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);
} }
} }
} }

View File

@@ -176,7 +176,8 @@ public class Poi implements
private void processAggStop(Tables.OsmPoiPoint element, FeatureCollector.Factory featureCollectors, private void processAggStop(Tables.OsmPoiPoint element, FeatureCollector.Factory featureCollectors,
Consumer<FeatureCollector.Feature> emit, Integer aggStop) { Consumer<FeatureCollector.Feature> emit, Integer aggStop) {
try { 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); setupPoiFeature(element, features.point(LAYER_NAME), aggStop);
for (var feature : features) { for (var feature : features) {
emit.accept(feature); emit.accept(feature);
@@ -209,7 +210,6 @@ public class Poi implements
processAggStop(aggStopSet.getFirst(), featureCollectors, emit, 1); processAggStop(aggStopSet.getFirst(), featureCollectors, emit, 1);
continue; continue;
} }
Tables.OsmPoiPoint nearest = null; Tables.OsmPoiPoint nearest = null;
try { try {
// find most important stops based on subclass // find most important stops based on subclass
@@ -228,7 +228,8 @@ public class Poi implements
double minDistance = Double.MAX_VALUE; double minDistance = Double.MAX_VALUE;
for (var aggStop : topAggStops) { for (var aggStop : topAggStops) {
double distance = aggStopCentroid.distance(aggStop.source().worldGeometry()); double distance = aggStopCentroid.distance(aggStop.source().worldGeometry());
if (distance < minDistance) { if (distance < minDistance || nearest == null ||
(distance == minDistance && aggStop.source().id() < nearest.source().id())) {
minDistance = distance; minDistance = distance;
nearest = aggStop; nearest = aggStop;
} }