Skip to content

Commit d0da681

Browse files
committed
feat(relations_with_no_way): skip relations which do not contain at least one way
1 parent a55f069 commit d0da681

6 files changed

+16
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ Output of the `nodes` array (as seen below) is optional, this was disabled by de
137137

138138
Since version `6.0` centroids and bounding boxes are also computed for relations, the calulations are based off the largest member way by area.
139139

140+
Note: if a `relation` does not contain at least one `way` then it will not be output.
141+
140142
### Leveldb
141143

142144
This library uses `leveldb` to store the lat/lon info about nodes so that it can denormalize the ways for you.

build/pbf2json.darwin-x64

4 KB
Binary file not shown.

build/pbf2json.linux-arm

0 Bytes
Binary file not shown.

build/pbf2json.linux-x64

4 KB
Binary file not shown.

build/pbf2json.win32-x64

1 KB
Binary file not shown.

pbf2json.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ func index(d *osmpbf.Decoder, masks *BitmaskMap, config settings) {
142142

143143
case *osmpbf.Relation:
144144
if hasTags(v.Tags) && containsValidTags(v.Tags, config.Tags) {
145+
146+
// record a count of which type of members
147+
// are present in the relation
148+
var count = make(map[int]int64)
149+
for _, member := range v.Members {
150+
count[int(member.Type)]++
151+
}
152+
153+
// skip relations which contain 0 ways
154+
if count[1] == 0 {
155+
continue
156+
}
157+
145158
masks.Relations.Insert(v.ID)
146159
for _, member := range v.Members {
147160
switch member.Type {
@@ -325,7 +338,7 @@ func print(d *osmpbf.Decoder, masks *BitmaskMap, db *leveldb.DB, config settings
325338
continue
326339
}
327340

328-
area := wayBounds.GeoWidth() * wayBounds.GeoHeight()
341+
area := math.Max(wayBounds.GeoWidth(), 0.000001) * math.Max(wayBounds.GeoHeight(), 0.000001)
329342

330343
// find the way with the largest area
331344
if area > largestArea {

0 commit comments

Comments
 (0)