filosganga / geogson

GeoJSON support for Google gson library
Apache License 2.0
68 stars 29 forks source link

multipoligon cast problem #36

Closed RafalJagielski closed 9 years ago

RafalJagielski commented 9 years ago

Hi I've got a shape defined as: substring = "{ \"type\": \"MultiPolygon\", \"coordinates\": [ [ [ [ 6.356486320495606, 49.525863647460938 ], [ 6.362777709960938, 49.489166259765625 ], [ 6.362170219421387, 49.459388732910156 ], [ 6.328332901000977, 49.469161987304688 ], [ 6.302777290344238, 49.476661682128906 ], [ 6.247318267822266, 49.505973815917969 ], [ 6.234721660614014, 49.508052825927734 ], [ 6.160694122314453, 49.504299163818359 ], [ 6.120242595672607, 49.476001739501953 ], [ 6.092499732971191, 49.453605651855469 ], [ 5.979582786560059, 49.448467254638672 ], [ 5.855277061462402, 49.501106262207031 ], [ 5.838610649108887, 49.51416015625 ], [ 5.810832977294922, 49.537635803222656 ], [ 5.807880401611328, 49.5450439453125 ], [ 5.835971832275391, 49.549720764160156 ], [ 5.863055229187012, 49.571662902832031 ], [ 5.900277137756348, 49.640548706054688 ], [ 5.899166107177734, 49.662773132324219 ], [ 5.876150131225586, 49.709884643554688 ], [ 5.869443893432617, 49.719718933105469 ], [ 5.790277481079102, 49.780830383300781 ], [ 5.752638339996338, 49.792285919189453 ], [ 5.734443664550781, 49.834999084472656 ], [ 5.747776985168457, 49.907493591308594 ], [ 5.778610706329346, 49.957008361816406 ], [ 5.834444046020508, 49.9869384765625 ], [ 5.883054733276367, 50.077217102050781 ], [ 5.887707710266113, 50.097427368164063 ], [ 5.973054885864258, 50.169998168945313 ], [ 6.017916202545166, 50.181804656982422 ], [ 6.026255607604981, 50.181251525878906 ], [ 6.03055477142334, 50.163051605224609 ], [ 6.119999885559082, 50.131942749023438 ], [ 6.134413719177246, 50.127845764160156 ], [ 6.129166126251221, 50.119163513183594 ], [ 6.118332862854004, 50.090827941894531 ], [ 6.113055229187012, 50.057357788085938 ], [ 6.130555152893066, 50.013885498046875 ], [ 6.140555381774902, 49.993888854980469 ], [ 6.174166202545166, 49.951107025146484 ], [ 6.234166145324707, 49.897499084472656 ], [ 6.252777576446533, 49.882358551025391 ], [ 6.315937995910645, 49.855316162109375 ], [ 6.321110725402832, 49.84832763671875 ], [ 6.39555549621582, 49.817771911621094 ], [ 6.429721832275391, 49.808883666992188 ], [ 6.481944084167481, 49.811103820800781 ], [ 6.524027347564697, 49.807701110839844 ], [ 6.505834579467773, 49.706626892089844 ], [ 6.472499370574951, 49.692981719970703 ], [ 6.420832633972168, 49.66583251953125 ], [ 6.356486320495606, 49.525863647460938 ] ] ] ] }";

and gets:

exception in thread "main" java.lang.ClassCastException: com.github.filosganga.geogson.model.positions.LinearPositions cannot be cast to com.github.filosganga.geogson.model.positions.MultiDimensionalPositions at com.github.filosganga.geogson.gson.GeometryAdapterFactory$GeometryAdapter$7.get(GeometryAdapterFactory.java:269) at com.github.filosganga.geogson.gson.GeometryAdapterFactory$GeometryAdapter$7.get(GeometryAdapterFactory.java:252) at com.github.filosganga.geogson.util.ChainableOptional.of(ChainableOptional.java:39) at com.github.filosganga.geogson.util.ChainableOptional.or(ChainableOptional.java:46) at com.github.filosganga.geogson.gson.GeometryAdapterFactory$GeometryAdapter.buildGeometry(GeometryAdapterFactory.java:135) at com.github.filosganga.geogson.gson.GeometryAdapterFactory$GeometryAdapter.read(GeometryAdapterFactory.java:117) at com.github.filosganga.geogson.gson.GeometryAdapterFactory$GeometryAdapter.read(GeometryAdapterFactory.java:64) at com.google.gson.Gson.fromJson(Gson.java:810) at com.google.gson.Gson.fromJson(Gson.java:775) at com.google.gson.Gson.fromJson(Gson.java:724) at com.google.gson.Gson.fromJson(Gson.java:696)

filosganga commented 9 years ago

Hi, which version are you using?

RafalJagielski commented 9 years ago

Hi, My pom entries are:

com.google.code.gson gson 2.3.1
    <dependency>
        <groupId>com.github.filosganga</groupId>
        <artifactId>geogson-core</artifactId>
        <version>1.1.72</version>
    </dependency>

geojson is generated from the shapefile by the QGIS app.

filosganga commented 9 years ago

Try to update to

geogson-core
1.1.88

please, because this seems to be an old bug.

RafalJagielski commented 9 years ago

indeed work well now. cheers, Rafal

filosganga commented 9 years ago

Great!