locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.95k stars 440 forks source link

com.vividsolutions.jts.io.ParseException: Unknown WKB type 10 #192

Closed uburoiubu closed 3 years ago

uburoiubu commented 6 years ago

Usingjts:1.13 I get the following exception: com.vividsolutions.jts.io.ParseException: Unknown WKB type 10

Here's the logcat:

10-09 11:00:07.490 29903-29903/work.phobos.flagman W/System.err: com.vividsolutions.jts.io.ParseException: Unknown WKB type 10
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.vividsolutions.jts.io.WKBReader.readGeometry(WKBReader.java:206)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.vividsolutions.jts.io.WKBReader.read(WKBReader.java:152)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.vividsolutions.jts.io.WKBReader.read(WKBReader.java:133)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at work.phobos.flagman.Utils.getListPointsFromBytes(Utils.java:191)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at work.phobos.flagman.VehicleCard.VehicleCardActivity$1.onMapReady(VehicleCardActivity.java:269)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onMapReady(MapView.java:945)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.mapbox.mapboxsdk.maps.MapView$MapCallback.access$1000(MapView.java:910)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.mapbox.mapboxsdk.maps.MapView$MapCallback$1.run(MapView.java:928)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at android.os.Handler.handleCallback(Handler.java:815)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:104)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at android.os.Looper.loop(Looper.java:207)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5763)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
dr-jts commented 6 years ago

Will need to see the input to dig into this issue. And JTS doesn't support a WKB type of 10, so perhaps the WKB is following an extension of the specification?

On Mon, Oct 9, 2017 at 1:02 AM, uburoiubu notifications@github.com wrote:

Usingjts:1.13 I get the following exception: com.vividsolutions.jts.io.ParseException: Unknown WKB type 10

Here's the logcat:

10-09 11:00:07.490 29903-29903/work.phobos.flagman W/System.err: com.vividsolutions.jts.io.ParseException: Unknown WKB type 10 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.vividsolutions.jts.io.WKBReader.readGeometry(WKBReader.java:206) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.vividsolutions.jts.io.WKBReader.read(WKBReader.java:152) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.vividsolutions.jts.io.WKBReader.read(WKBReader.java:133) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at work.phobos.flagman.Utils.getListPointsFromBytes(Utils.java:191) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at work.phobos.flagman.VehicleCard.VehicleCardActivity$1.onMapReady(VehicleCardActivity.java:269) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onMapReady(MapView.java:945) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.mapbox.mapboxsdk.maps.MapView$MapCallback.access$1000(MapView.java:910) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.mapbox.mapboxsdk.maps.MapView$MapCallback$1.run(MapView.java:928) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at android.os.Handler.handleCallback(Handler.java:815) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at android.os.Handler.dispatchMessage(Handler.java:104) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at android.os.Looper.loop(Looper.java:207) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5763) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at java.lang.reflect.Method.invoke(Native Method) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888) 10-09 11:00:07.491 29903-29903/work.phobos.flagman W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/locationtech/jts/issues/192, or mute the thread https://github.com/notifications/unsubscribe-auth/ADXZXRh9e9I2Mz_EFCwcI4QcVoaBJt52ks5sqdL7gaJpZM4PyHlG .

jnh5y commented 6 years ago

Indeed, we need a way to reproduce this. Usually when I see issues like this, it is because of an error about where my code starts to read a byte array.

Without a documented way to reproduce, my inclination will be to close this ticket in a week or so.

uburoiubu commented 6 years ago

@jnh5y, here's the method:

public static ArrayList<double[]> getArrayPointsFromBytes(byte[] shapeBytes) {

        ArrayList<double[]> polygon = new ArrayList<>();

        WKBReader reader = wkbReader.get();

        try {
            Geometry geom = reader.read(shapeBytes);
            geom.isValid();
            Coordinate[] coordinates = geom.getCoordinates();
            for (Coordinate c : coordinates) {
                polygon.add(new double[] {c.x, c.y});
            }

        } catch (ParseException e) {
            Log.e("getListFromPoints: ", e.getMessage());
            e.printStackTrace();
        }

        return polygon;
    }
dr-jts commented 6 years ago

We need to see the actual input value, not just the code.

uburoiubu commented 6 years ago

@dr-jts, I got it.

shapeBytes from the method mentioned above that throw an exception:

[1, 10, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, 0, 0, 5, 0, 0, 0, 22, 70, -8, 84, 106, 51, 67, 64, 51, -86, -109, -122, -59, -21, 75, 64, 109, 125, -40, -115, 65, 51, 67, 64, 51, -86, -109, -122, -59, -21, 75, 64, 59, -127, -16, -115, 65, 51, 67, 64, -86, 123, 62, -95, -82, -21, 75, 64, 72, 66, -32, 84, 106, 51, 67, 64, -86, 123, 62, -95, -82, -21, 75, 64, 22, 70, -8, 84, 106, 51, 67, 64, 51, -86, -109, -122, -59, -21, 75, 64]

And I don't know if that's helpful, but here's backtrace from the exception:

screen shot 2017-11-01 at 13 22 03

dr-jts commented 3 years ago

Closing due to incomplete information.

tsmock commented 1 year ago

I ran into this same issue, but with WKB type 9 (COMPOUNDCURVE). I suspect the original reporter was using CURVEPOLYGON as the geometry type (see https://www.geopackage.org/spec120/#geometry_types_extension ).

See also #443 (CIRCULARSTRING, WKB type 8).