Skip to content

Commit

Permalink
feat(relations_with_no_way): skip relations which do not contain at l…
Browse files Browse the repository at this point in the history
…east one way
  • Loading branch information
missinglink committed Jun 13, 2019
1 parent a55f069 commit d0da681
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Output of the `nodes` array (as seen below) is optional, this was disabled by de

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

Note: if a `relation` does not contain at least one `way` then it will not be output.

### Leveldb

This library uses `leveldb` to store the lat/lon info about nodes so that it can denormalize the ways for you.
Expand Down
Binary file modified build/pbf2json.darwin-x64
Binary file not shown.
Binary file modified build/pbf2json.linux-arm
Binary file not shown.
Binary file modified build/pbf2json.linux-x64
Binary file not shown.
Binary file modified build/pbf2json.win32-x64
Binary file not shown.
15 changes: 14 additions & 1 deletion pbf2json.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ func index(d *osmpbf.Decoder, masks *BitmaskMap, config settings) {

case *osmpbf.Relation:
if hasTags(v.Tags) && containsValidTags(v.Tags, config.Tags) {

// record a count of which type of members
// are present in the relation
var count = make(map[int]int64)
for _, member := range v.Members {
count[int(member.Type)]++
}

// skip relations which contain 0 ways
if count[1] == 0 {
continue
}

masks.Relations.Insert(v.ID)
for _, member := range v.Members {
switch member.Type {
Expand Down Expand Up @@ -325,7 +338,7 @@ func print(d *osmpbf.Decoder, masks *BitmaskMap, db *leveldb.DB, config settings
continue
}

area := wayBounds.GeoWidth() * wayBounds.GeoHeight()
area := math.Max(wayBounds.GeoWidth(), 0.000001) * math.Max(wayBounds.GeoHeight(), 0.000001)

// find the way with the largest area
if area > largestArea {
Expand Down

0 comments on commit d0da681

Please sign in to comment.