Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiPoint geometries only draw one point #62

Closed
e-n-f opened this issue Oct 2, 2014 · 9 comments
Closed

MultiPoint geometries only draw one point #62

e-n-f opened this issue Oct 2, 2014 · 9 comments

Comments

@e-n-f
Copy link
Contributor

e-n-f commented Oct 2, 2014

@springmeyer, as we just discussed on chat, I have been trying to use multipoint geometries in Mapbox Studio.

As a test, I uploaded this GeoJSON file to mapbox.com as map ID enf.tqgmbo6r.

It looks like each MultiPoint draws as a single point at the centroid of the points within each feature within each tile rather than drawing all the points, regardless of how marker-multi-policy is set:

screen shot 2014-10-01 at 5 32 01 pm

As individual points (enf.6vjqncdi) it looks like this:

screen shot 2014-10-01 at 5 35 03 pm

but the file is twice as large with each point in its own feature.

@pnorman
Copy link
Contributor

pnorman commented Oct 9, 2014

I can definitely confirm this an issue - I've run into it using the API directly, not in MapBox Studio.

My testcase:

Saved as test/single_multipoint.xml

<Map
    srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
    maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
  <Layer name="point" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
id|name|wkt
1|null island|MultiPoint((-1000000 0), (0 0), (1000000 0))
      </Parameter>
    </Datasource>
  </Layer>
</Map>
void test_multipoint() {
/* This test uses a map file with a CSV source with a multipoint and checks
 * the resulting vector tile at 0/0/0
 */
  mapnik::Map map;
  avecado::tile tile;
  mapnik::load_map(map, "test/single_multipoint.xml");
  map.resize(tile_size, tile_size);
  map.zoom_to_box(bbox);
  avecado::make_vector_tile(tile, path_multiplier, map, buffer_size, scale_factor,
                            offset_x, offset_y, tolerance, image_format,
                            scaling_method, scale_denominator, boost::none);
  mapnik::vector::tile result;
  result.ParseFromString(tile.get_data());
  test::assert_equal(result.layers_size(), 1, "Wrong number of layers");
  mapnik::vector::tile_layer layer = result.layers(0);

  // Query the layer with mapnik. See https://github.com/mapbox/mapnik-vector-tile/blob/2e3e2c28/test/vector_tile.cpp#L236
  mapnik::vector::tile_datasource ds(layer, 0, 0, 0, tile_size);

  mapnik::query qq = mapnik::query(bbox);
  qq.add_property_name("name");
  mapnik::featureset_ptr fs;
  fs = ds.features(qq);
  mapnik::feature_ptr feat = fs->next();
  std::string json = feature_to_geojson(*feat);
  test::assert_equal(json, blank, "Wrong JSON");
}

The geojson contains a Point, not a MultiPoint
In this case, avecado::make_vector_tile just returns painted() from a mapnik::vector::processor<mapnik::vector::backend_pbf>, after setting up stuff.

@pnorman
Copy link
Contributor

pnorman commented Oct 9, 2014

@ericfischer did you have occasion to test with MULTILINESTRINGs or MULTIPOLYGONs?

@e-n-f
Copy link
Contributor Author

e-n-f commented Oct 9, 2014

@pnorman They both worked fine for me when I tried, although the multipolygon only gets one label even if you ask for marker-multi-policy: each.

@pnorman
Copy link
Contributor

pnorman commented Oct 10, 2014

the multipolygon only gets one label even if you ask for marker-multi-policy: each

Given how polygons interact with tile boundaries, that's probably not an issue for common usages, but may be for other consumption of vector tiles.

I'll see what I get back with vector tiles from a datasource with the other MULTI* geometries, so I'll test and serialize the results to something human-readable.

pnorman added a commit to MapQuest/avecado that referenced this issue Oct 10, 2014
mapnik/mapnik#2518 prevents checking the GeoJSON, so instead the feature geometry is queried manually.

mapbox/mapnik-vector-tile#62 prevents MultiPoints from working with mapnik-vector-tile, so they don't work in Avecado either

ref mapbox/vector-tile-spec#18
@springmeyer
Copy link
Contributor

@ericfischer as discussed on chat, I think a good solution is to add a new mapnik symbolizer for fast rendering of multipoints. Let's call it the dot symbolizer for now. I've stubbed out:

After you've got Mapnik to a point you'd like to test then we'd together create new node-mapnik packages via a dots branch (https://github.com/mapnik/node-mapnik/compare/dots) and then point Mapbox studio at it like:

diff --git a/package.json b/package.json
index 81b2f62..0ca8dd3 100644
--- a/package.json
+++ b/package.json
@@ -31,8 +31,8 @@
     "js-yaml": "https://github.com/mapbox/js-yaml/tarball/scalar-styles",
     "fstream": "0.1.x",
     "tar": "0.1.x",
-    "mapnik": "1.4.17",
-    "mapnik-reference": "~6.0.1",
+    "mapnik": "https://github.com/mapnik/node-mapnik/tarball/dots",
+    "mapnik-reference": "https://github.com/mapnik/mapnik/-reference/tarball/dots",
     "carto": "0.14.0",
     "speedometer": "0.1.2",
     "tilelive": "5.2.3",

@e-n-f
Copy link
Contributor Author

e-n-f commented Oct 18, 2014

Thank you @springmeyer! It will probably be a few days before I am able to get started on this but I am looking forward to it.

@springmeyer
Copy link
Contributor

tl;dr: Closing this, next actions at mapnik/mapnik#2611.

To recap:

@pnorman
Copy link
Contributor

pnorman commented Apr 1, 2015

Does #98 and multipoints not existing in the spec change this?

@springmeyer
Copy link
Contributor

@pnorman multipoints are supported in the spec and always have been: they are type POINT and encoded as multiple move_to commands rather than just one (for a single point).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants