tyrasd / osmtogeojson

convert osm to geojson
http://tyrasd.github.io/osmtogeojson/
MIT License
683 stars 112 forks source link

my attempt to use polygonFeatures callback function failed #104

Open matkoniecz opened 5 years ago

matkoniecz commented 5 years ago

I used osmtogeojson map.osm polygonFeatures="function(){return false;}" > test.geojson with map.osm containing

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.6.1 (1889 thorn-03.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
 <bounds minlat="50.5830900" minlon="20.4023700" maxlat="50.5835800" maxlon="20.4043800"/>
 <node id="4128196777" visible="true" version="1" changeset="38642793" timestamp="2016-04-17T15:37:08Z" user="Władysław Komorek" uid="693154" lat="50.5831571" lon="20.4041403"/>
 <node id="4128196781" visible="true" version="1" changeset="38642793" timestamp="2016-04-17T15:37:14Z" user="Władysław Komorek" uid="693154" lat="50.5833687" lon="20.4041873"/>
 <node id="4128199242" visible="true" version="1" changeset="38642793" timestamp="2016-04-17T15:37:12Z" user="Władysław Komorek" uid="693154" lat="50.5832881" lon="20.4026850"/>
 <node id="4128225757" visible="true" version="1" changeset="38642793" timestamp="2016-04-17T15:37:15Z" user="Władysław Komorek" uid="693154" lat="50.5834996" lon="20.4027320"/>
 <way id="348329727" visible="true" version="2" changeset="38642793" timestamp="2016-04-17T15:38:40Z" user="Władysław Komorek" uid="693154">
  <nd ref="4128225757"/>
  <nd ref="4128199242"/>
  <nd ref="4128196777"/>
  <nd ref="4128196781"/>
  <nd ref="4128225757"/>
  <tag k="building" v="yes"/>
 </way>
</osm>

I got polygon instead of expected line in the output. osmtogeojson was not emitting any warnings.

"type": "FeatureCollection",
"features": [
{
  "type": "Feature",
  "id": "way/348329727",
  "properties": {
    "timestamp": "2016-04-17T15:38:40Z",
    "version": "2",
    "changeset": "38642793",
    "user": "Władysław Komorek",
    "uid": "693154",
    "building": "yes",
    "id": "way/348329727"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          20.402732,
          50.5834996
        ],
        [
          20.402685,
          50.5832881
        ],
        [
          20.4041403,
          50.5831571
        ],
        [
          20.4041873,
          50.5833687
        ],
        [
          20.402732,
          50.5834996
        ]
      ]
    ]
  }
}
]
}

osmtogeojson --version gives 3.0.0-beta.3

It seems to be the latest available

[sudo] password for mateusz: 
Sorry, try again.
[sudo] password for mateusz: 
npm WARN deprecated geojson-area@0.1.0: This module is now under the @mapbox namespace: install @mapbox/geojson-area instead
/usr/local/bin/osmtogeojson -> /usr/local/lib/node_modules/osmtogeojson/osmtogeojson
+ osmtogeojson@3.0.0-beta.3
updated 1 package in 7.519s