Factual / geo

Clojure library for working with geohashes, polygons, and other world geometry
Eclipse Public License 1.0
303 stars 17 forks source link

to-geojson fail on a simple polygon #74

Open 0xbase12 opened 2 years ago

0xbase12 commented 2 years ago
(require '[geo.io :as gio])
=> nil

; read-wkt is ok 
(gio/read-wkt "POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))")
=> #object[org.locationtech.jts.geom.Polygon 0x223e81a9 "POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"]

; issue and exception thrown
(gio/to-geojson (gio/read-wkt "POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"))
Execution error (NoSuchMethodError) at org.wololo.jts2geojson.GeoJSONWriter/convert (GeoJSONWriter.java:79).
'org.locationtech.jts.geom.LineString org.locationtech.jts.geom.Polygon.getExteriorRing()'

Simple fix is perhaps by updating libraries: https://github.com/locationtech/spatial4j/issues/192

0xbase12 commented 2 years ago

To make it work, I used following versions:

   [factual/geo "3.0.1" :exclusions [[org.locationtech.jts/jts-core]
                                     [org.locationtech.spatial4j/spatial4j]
                                     [org.wololo/jts2geojson]]]
   [org.locationtech.spatial4j/spatial4j "0.8"]
   [org.locationtech.jts/jts-core "1.18.2"]
   [org.wololo/jts2geojson "0.15.0"]]

When I use [org.wololo/jts2geojson "0.16.1"]] I'm hitting an issue at repl load time of geo.io namespace.

worace commented 2 years ago

@0xbase12 that seems like a great find. Any chance you'd be able to open a PR bumping those versions? Would be great to include your example as a test case as well.