-
Notifications
You must be signed in to change notification settings - Fork 69
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
OpenMapTiles 3.15.0 SNAPSHOT #126
Changes from 87 commits
0bb61f7
d32501e
862e50a
8998ddd
14c204d
fcfe115
91b1842
05b91a7
096b1a4
fda198f
74f655b
cf92b5e
be4ac2d
32c59d1
4e3f0fd
da044ca
436e3b3
6354264
984b7f2
4702e31
1e1b896
8750c78
7418117
bfce42e
65f672f
213dd14
77e6aea
1fa4181
03f2b04
7a718e6
a93cc9e
17604dc
f06187a
5b6a46c
e46c44c
258db80
62814fe
d3429c4
7f96e66
137a89a
0672adf
6a099de
afbd863
19a75a0
899a0c5
7043e8c
b597ecf
604f22b
ed7e357
3470989
3876d6b
bca12e2
7a22bc6
cf9e850
22029f1
26680da
37c657d
ac6bb21
f6c4ace
72abc21
6125d70
b7e7f4c
00560b3
5d08720
397efef
dca9671
8654d86
8e1703b
6c05d7d
b6cda03
338329a
9b59981
a7bcfa9
30dab9f
f50e2b7
1ddfb9a
0a2565d
59b3078
d3434f9
50273b0
124b1dc
93bdca5
8c200bd
c9c5f01
43d16a9
269575b
e58b60e
45abdbe
124d000
91d5e82
d93ca1f
8380e2f
1a9a333
9886cb1
654e08a
1f64f5f
0f8487e
35442fa
99704bf
eb46f86
bfaa676
4374adf
371206c
e21c74a
f499467
caa41e1
a20d488
b9db64a
9ab8f47
32982da
3cbe8c8
912538b
a0569fd
5bab4cf
a5eabee
dc8a179
7a09981
60ee412
6863915
23d9ba7
602036c
e11f9c6
f5fe5fe
27f57a3
ac14a04
f390550
3b363cb
360751e
503eee8
212c80c
28b75a7
6dcd29d
612f700
d756038
08ee4da
c8c4b24
57c2547
82bb68a
7eed2ac
59fa9ac
60be59b
a0b7443
3b0959b
69393d0
bdea325
6aa4e88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -43,9 +43,15 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||||||
import com.onthegomap.planetiler.geo.GeometryException; | ||||||||
import com.onthegomap.planetiler.stats.Stats; | ||||||||
import com.onthegomap.planetiler.util.Translations; | ||||||||
import java.util.Arrays; | ||||||||
import java.util.List; | ||||||||
import java.util.regex.Matcher; | ||||||||
import java.util.regex.Pattern; | ||||||||
import java.util.stream.Collectors; | ||||||||
import org.openmaptiles.generated.OpenMapTilesSchema; | ||||||||
import org.openmaptiles.generated.Tables; | ||||||||
import org.slf4j.Logger; | ||||||||
import org.slf4j.LoggerFactory; | ||||||||
|
||||||||
/** | ||||||||
* Defines the logic for generating map elements in the {@code housenumber} layer from source features. | ||||||||
|
@@ -59,13 +65,63 @@ public class Housenumber implements | |||||||
Tables.OsmHousenumberPoint.Handler, | ||||||||
ForwardingProfile.FeaturePostProcessor { | ||||||||
|
||||||||
public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) {} | ||||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Housenumber.class); | ||||||||
private static final Character OSM_SEPARATOR = ';'; | ||||||||
private static final String DISPLAY_SEPARATOR = "–"; | ||||||||
private static final Pattern NO_CONVERSION_PATTERN = Pattern.compile("[^0-9;]"); | ||||||||
private final Stats stats; | ||||||||
|
||||||||
public Housenumber(Translations translations, PlanetilerConfig config, Stats stats) { | ||||||||
this.stats = stats; | ||||||||
} | ||||||||
|
||||||||
private static String displayHousenumberNonumeric(String[] numbers) { | ||||||||
return numbers[0] | ||||||||
.concat(DISPLAY_SEPARATOR) | ||||||||
.concat(numbers[numbers.length - 1]); | ||||||||
} | ||||||||
|
||||||||
protected static String displayHousenumber(String housenumber) { | ||||||||
if (housenumber.indexOf(OSM_SEPARATOR) < 0) { | ||||||||
return housenumber; | ||||||||
} | ||||||||
|
||||||||
String[] numbers = Arrays.stream(housenumber.split(OSM_SEPARATOR.toString())) | ||||||||
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. Since we're using java 21 now, if you make this a list with 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. Adjusted. |
||||||||
.filter(n -> !n.trim().isEmpty()) | ||||||||
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. Do we want to trim the output?
Suggested change
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. Yup, definitely. Adjusted. |
||||||||
.toArray(String[]::new); | ||||||||
if (numbers.length <= 0) { | ||||||||
// not much to do with strange/invalid entries like "3;" or ";" etc. | ||||||||
return housenumber; | ||||||||
} | ||||||||
|
||||||||
Matcher matcher = NO_CONVERSION_PATTERN.matcher(housenumber); | ||||||||
if (matcher.find()) { | ||||||||
return displayHousenumberNonumeric(numbers); | ||||||||
} | ||||||||
|
||||||||
// numeric display house number | ||||||||
var statistics = Arrays.stream(numbers) | ||||||||
.collect(Collectors.summarizingInt(Integer::parseUnsignedInt)); | ||||||||
return String.valueOf(statistics.getMin()) | ||||||||
.concat(DISPLAY_SEPARATOR) | ||||||||
.concat(String.valueOf(statistics.getMax())); | ||||||||
} | ||||||||
|
||||||||
@Override | ||||||||
public void process(Tables.OsmHousenumberPoint element, FeatureCollector features) { | ||||||||
String housenumber; | ||||||||
try { | ||||||||
housenumber = displayHousenumber(element.housenumber()); | ||||||||
phanecak-maptiler marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
} catch (NumberFormatException e) { | ||||||||
// should not be happening (thanks to NO_CONVERSION_PATTERN) but ... | ||||||||
stats.dataError("housenumber_range"); | ||||||||
LOGGER.warn("Failed to convert housenumber range: {}", element.housenumber()); | ||||||||
phanecak-maptiler marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
housenumber = element.housenumber(); | ||||||||
} | ||||||||
|
||||||||
features.centroidIfConvex(LAYER_NAME) | ||||||||
.setBufferPixels(BUFFER_SIZE) | ||||||||
.setAttr(Fields.HOUSENUMBER, element.housenumber()) | ||||||||
.setAttr(Fields.HOUSENUMBER, housenumber) | ||||||||
.setMinZoom(14); | ||||||||
} | ||||||||
|
||||||||
|
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.
Minor: would be a little easier to follow. OSM_SEPARATOR would need to be a string
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.
Adjusted.