-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add house numbers layer #336
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,9 @@ export interface Theme { | |
state_label_halo: string; | ||
country_label: string; | ||
|
||
housenumbers_label: string; | ||
house_numbers_label_halo: string; | ||
|
||
regular?: string; | ||
bold?: string; | ||
italic?: string; | ||
|
@@ -188,6 +191,9 @@ export const CONTRAST: Theme = { | |
state_label: "#777777", | ||
state_label_halo: "#ffffff", | ||
country_label: "#9590aa", | ||
|
||
housenumbers_label: "#91888b", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
house_numbers_label_halo: "#ffffff", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe |
||
}; | ||
|
||
export const LIGHT: Theme = { | ||
|
@@ -270,6 +276,9 @@ export const LIGHT: Theme = { | |
state_label_halo: "#e0e0e0", | ||
country_label: "#a3a3a3", | ||
|
||
housenumbers_label: "#91888b", | ||
house_numbers_label_halo: "#ffffff", | ||
|
||
pois: { | ||
blue: "#1A8CBD", | ||
green: "#20834D", | ||
|
@@ -372,6 +381,9 @@ export const DARK: Theme = { | |
state_label_halo: "#1f1f1f", | ||
country_label: "#5c5c5c", | ||
|
||
housenumbers_label: "#525252", | ||
house_numbers_label_halo: "#1f1f1f", | ||
|
||
pois: { | ||
blue: "#4299BB", | ||
green: "#30C573", | ||
|
@@ -473,6 +485,9 @@ export const WHITE: Theme = { | |
state_label: "#b3b3b3", | ||
state_label_halo: "#ffffff", | ||
country_label: "#b8b8b8", | ||
|
||
housenumbers_label: "#adadad", | ||
house_numbers_label_halo: "#ffffff", | ||
}; | ||
|
||
export const GRAYSCALE: Theme = { | ||
|
@@ -554,6 +569,9 @@ export const GRAYSCALE: Theme = { | |
state_label: "#999999", | ||
state_label_halo: "#cccccc", | ||
country_label: "#858585", | ||
|
||
housenumbers_label: "#999999", | ||
house_numbers_label_halo: "#e0e0e0", | ||
}; | ||
|
||
export const BLACK: Theme = { | ||
|
@@ -635,6 +653,9 @@ export const BLACK: Theme = { | |
state_label: "#3d3d3d", | ||
state_label_halo: "#141414", | ||
country_label: "#707070", | ||
|
||
housenumbers_label: "#525252", | ||
house_numbers_label_halo: "#141414", | ||
}; | ||
|
||
const themes: Record<string, Theme> = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,12 @@ | |
import com.onthegomap.planetiler.util.Parse; | ||
import com.protomaps.basemap.feature.FeatureId; | ||
import com.protomaps.basemap.postprocess.Area; | ||
|
||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
|
||
public class Buildings implements ForwardingProfile.LayerPostProcesser { | ||
|
@@ -93,13 +98,46 @@ public void processOsm(SourceFeature sf, FeatureCollector features) { | |
// Names should mostly just be for POIs | ||
// Sometimes building name and address are useful items, but only at zoom 17+ | ||
//OsmNames.setOsmNames(feature, sf, 13); | ||
} else if (sf.hasTag("addr:housenumber")) { | ||
FeatureCollector.Feature feature = null; | ||
if (sf.isPoint()) { | ||
feature = features.point(this.name()); | ||
} else if (sf.canBePolygon()) { | ||
feature = features.centroid(this.name()); | ||
} | ||
if (feature != null) { | ||
feature | ||
.setId(FeatureId.create(sf)) | ||
.setAttr("addr_housenumber", sf.getString("addr:housenumber")) | ||
.setAttr("addr_street", sf.getString("addr:street")) | ||
.setAttr("kind", "address") | ||
.setMinZoom(15); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) throws GeometryException { | ||
if (zoom == 15) { | ||
return items; | ||
List<VectorTile.Feature> buildings = new ArrayList<>(); | ||
|
||
// deduplicate addresses | ||
HashMap<Map<String, Object>, List<VectorTile.Feature>> groupedAddresses = new LinkedHashMap<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this meant to address one building that is labeled twice on the map? Is there a specific place in the world where that problem is pervasive or is it an edge case where maybe it's a data problem in OSM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NVM, I see the issue is that it also includes POIs that have an |
||
for (VectorTile.Feature item : items) { | ||
if (item.tags().containsKey("addr_housenumber")) { | ||
groupedAddresses.computeIfAbsent(item.tags(), k -> new ArrayList<>()).add(item); | ||
} else { | ||
buildings.add(item); | ||
} | ||
} | ||
|
||
for (var address : groupedAddresses.values()) { | ||
var feature = address.get(0); | ||
feature.tags().remove("addr_street"); | ||
bdon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
buildings.add(feature); | ||
} | ||
|
||
return buildings; | ||
} | ||
items = Area.filterArea(items, 0); | ||
|
||
|
@@ -151,7 +189,6 @@ public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> i | |
} | ||
} | ||
} | ||
|
||
return FeatureMerge.mergeNearbyPolygons(items, 3.125, 3.125, 0.5, 0.5); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be an opt-in instead of an opt-out, e.g.
kind
inbuilding
orbuilding_part