wdtinc / mapbox-vector-tile-java

Java Mapbox Vector Tile Library for Encoding/Decoding
Apache License 2.0
147 stars 73 forks source link

problem with polygon #7

Closed mnameghi closed 7 years ago

mnameghi commented 7 years ago

I'd tried to create mvt from polygon but there is a problem in rendering it. I Read.me explain something about Buffering Polygons but I can't find this method:

// Build buffered MVT tile geometry
final TileGeomResult bufferedTileGeom = JtsAdapter.createTileGeom(
        JtsAdapter.flatFeatureList(inputGeom),
        tileEnvelope, clipEnvelope, geomFactory,
        DEFAULT_MVT_PARAMS, ACCEPT_ALL_FILTER);
ShibaBandit commented 7 years ago

Hey, I'll need some more information in order to help out. Would recommend starting with:

  1. mapbox-vector-tile-java version you are using
  2. Relevant excerpt from your code
  3. Your inputs

You could double check you are on the latest library version, otherwise that method with a separate clipping envelope will not be available (see changelog). A troubleshooting method you could try is try alternate geometry, start with something simple and see if that works correctly also.

mnameghi commented 7 years ago

Hi I used last version. this is my code:

VectorTile.Tile.Layer.Builder area = MvtLayerBuild.newLayerBuilder("area", layerParams);
List<Geometry> areaGeometries = new ArrayList<>();
List<Geometry> areaGeometries = new ArrayList<>();
for (AreaEntity at : areaEntities) {
    Geometry geometry = at.getShape();
    Map<String, Object> map = new HashMap<>();
    map.put("type", at.getType());
    map.put("area",at.getArea());
    areaGeometries.add(g);
    geometry.setUserData(map);
    areaGeometries.add(geometry);
}

final GeometryFactory geomFactory = new GeometryFactory();
final TileGeomResult tileGeom = JtsAdapter.createTileGeom(
        geometries,
        envelope,
        geomFactory,
        defaultMvtParam,
        acceptAllGeomFilter
);

final MvtLayerProps layerProps = new MvtLayerProps();
List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(tileGeom.mvtGeoms, layerProps, userDataConverter);

builder.addAllFeatures(features);
MvtLayerBuild.writeProps(builder, layerProps);
tileBuilder.addLayers(builder.build());
VectorTile.Tile mvt = tileBuilder.build();

and I used osm data. With line and point data everything is OK, but polygons data are not showed on my map!

mnameghi commented 7 years ago

OK I found my fault! I used wrong version and now I found that function. but there is problem with polygon!

ShibaBandit commented 7 years ago

Maybe try starting with something simple like the write example:

https://github.com/wdtinc/mapbox-vector-tile-java/blob/master/src/test/java/com/wdtinc/mapbox_vector_tile/MvtBuildTest.java

See if you can get that working, then add in your logic and isolate the issue you are experiencing some more.

ShibaBandit commented 7 years ago

Feel free to re-open when you've isolated your problem more.