opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

Polygon hole can not show on VectorLayer #178

Open sunshine0576 opened 6 years ago

sunshine0576 commented 6 years ago

when i add "PolygonDrawable " to the VectorLayer Polygon holes cannot be drawn,Is there a way to solve this problem?,Is my style wrong?

VectorLayer vectorLayer = new VectorLayer(mMap); Polygon shell =(Polygon) new GeomBuilder() .point(0, 0) .point() .buffer(20) .get();

    Polygon hole = (Polygon)new GeomBuilder()
            .point(0, 0)
            .point()
            .buffer(10)
            .get();

    Polygon polygon=new GeometryFactory().createPolygon((LinearRing) shell.getExteriorRing(),
            new LinearRing[]{(LinearRing)hole.getExteriorRing()});

    vectorLayer.add(new PolygonDrawable(polygon, defaultStyle()));
sunshine0576 commented 6 years ago

polygon

devemux86 commented 6 years ago

VTM development continues at https://github.com/mapsforge/vtm.

For questions please use our forum.

devemux86 commented 6 years ago

Since have not asked in https://github.com/mapsforge/vtm or in forum, I post the answer here.

Depends if JTS geometries are properly constructed, e.g. JTS polygons should have their exterior shell in clockwise direction and their interior holes in counter-clockwise direction. So can normalize the created JTS polygon to handle that:

polygon.normalize();

polygons