GithubHelp home page GithubHelp logo

Comments (9)

wlievens avatar wlievens commented on June 15, 2024 1

I tried your clip branch and it works! Thanks for taking care of this so quickly, I hope we'll see this code in a new mainline release soon.

from mapbox-vector-tile-java.

ShibaBandit avatar ShibaBandit commented on June 15, 2024

We can try out a scenario / option supporting clipping outside the tile boundary by some buffer distance. It would be correct to say that the tiles are clipped on the boundary.

Question: How are you styling the vector tiles? I imagine clipping on the boundary might be causing issues with styles that use an outline on the geometry?

from mapbox-vector-tile-java.

ShibaBandit avatar ShibaBandit commented on June 15, 2024

Another question... does the leaflet plugin use the protobuf id field at all for reconstructing polygons?

from mapbox-vector-tile-java.

wlievens avatar wlievens commented on June 15, 2024

The leaflet plugin's documentation tells me there should indeed be a buffer around the tile envelope, and if I'm correct there's no parameter for specifying that.

from mapbox-vector-tile-java.

wlievens avatar wlievens commented on June 15, 2024

As for the id fieldn do not know for suee, but I do see polygons highlighted as one feature, so they are matched somehow.

from mapbox-vector-tile-java.

ShibaBandit avatar ShibaBandit commented on June 15, 2024

Do you want to try the clip_buffering branch at https://github.com/wdtinc/mapbox-vector-tile-java/tree/clip_buffering ? There is a new overload for JtsAdapter#createTileGeom() that supports passing in a clipping envelope as a new parameter.

    /**
     * <p>Create geometry clipped and then converted to MVT 'extent' coordinates. Result
     * contains both clipped geometry (intersection) and transformed geometry for encoding to MVT.</p>
     *
     * <p>Allows specifying separate tile and clipping coordinates. {@code clipEnvelope} can be bigger than
     * {@code tileEnvelope} to have geometry exist outside the MVT tile extent.</p>
     *
     * @param g original 'source' geometry, passed through {@link #flatFeatureList(Geometry)}
     * @param tileEnvelope world coordinate bounds for tile, used for transforms
     * @param clipEnvelope world coordinates to clip tile by
     * @param geomFactory creates a geometry for the tile envelope
     * @param mvtLayerParams specifies vector tile properties
     * @param filter geometry values that fail filter after transforms are removed
     * @return tile geometry result
     * @see TileGeomResult
     */
    public static TileGeomResult createTileGeom(List<Geometry> g,
                                                Envelope tileEnvelope,
                                                Envelope clipEnvelope,
                                                GeometryFactory geomFactory,
                                                MvtLayerParams mvtLayerParams,
                                                IGeometryFilter filter) {
    ...

I've created an example test in MvtBuiltTest#testBufferedPolygon()

        // Create input geometry
        final GeometryFactory geomFactory = new GeometryFactory();
        final Geometry inputGeom = buildPolygon(RANDOM, 200, geomFactory);

        // Build tile envelope - 1 quadrant of the world
        final double tileWidth = WORLD_SIZE * .5d;
        final double tileHeight = WORLD_SIZE * .5d;
        final Envelope tileEnvelope = new Envelope(0d, tileWidth, 0d, tileHeight);

        // Build clip envelope - (10 * 2)% buffered area of the tile envelope
        final Envelope clipEnvelope = new Envelope(tileEnvelope);
        final double bufferWidth = tileWidth * .1f;
        final double bufferHeight = tileHeight * .1f;
        clipEnvelope.expandBy(bufferWidth, bufferHeight);

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

        // Create MVT layer
        final VectorTile.Tile mvt = encodeMvt(DEFAULT_MVT_PARAMS, bufferedTileGeom);

from mapbox-vector-tile-java.

ShibaBandit avatar ShibaBandit commented on June 15, 2024

Screenshot shows original random geometry hull (dark green), tile geometry (brown), clip geometry (light green).

screen shot 2017-07-05 at 2 01 43 pm

from mapbox-vector-tile-java.

ShibaBandit avatar ShibaBandit commented on June 15, 2024

Should be able to push this to maven central soon as a new version soon in combination with some new README info.

from mapbox-vector-tile-java.

ShibaBandit avatar ShibaBandit commented on June 15, 2024

Closed via #6

from mapbox-vector-tile-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.