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

featuresAt returns bucketType as designated in stylesheet, refs #876 #879

Merged
merged 3 commits into from
Dec 17, 2014

Conversation

lbud
Copy link
Contributor

@lbud lbud commented Dec 11, 2014

Per #876, this adds a _bucketType property to features returned in map.featuresAt that indicates the layer type specified in the stylesheet, so it would return something like

{
    "_bucket" : "landcover_copy",
    "_bucketType" : "line",
    "_type" : "Polygon",
    "properties" : {
        "class" : "scrub"
    },
    "extent" : 4096,
    "type" : 3
}

This is a really simple fix for the specific problem I'm having in a project, but I think requires further discussion on the actual intent/use for featuresAt — is this 👍 or should it return more info? (Also, if this is sufficient, we should probably rename the returned _type property — _geometryType?)

cc @jfirebaugh @ansis @kkaefer @edenh @mourner @tmcw

@lbud
Copy link
Contributor Author

lbud commented Dec 11, 2014

hm hold on, something's broken was #880

@jfirebaugh
Copy link
Contributor

The results should use terms that are consistent with the rest of the API and style-spec. So, "layer", "source", "layout", "paint", "$type".

How about:

{
  "$type": "Polygon",
  "properties": {
    ...
  },
  "layer": {
    "id": "landcover_copy",
    "type": "line",
    "layout": {
      ... calculated layout properties ...
    },
    "paint": {
      ... calculated paint properties ...
    }
  },
  "source": {
    "id": "mapbox",
    "url": "mapbox://mapbox.mapbox-streets-v6-dev"
  }
}

@lbud
Copy link
Contributor Author

lbud commented Dec 12, 2014

Now returning

{
  "$type": "line",
  "layer": {
    "id": "waterway",
    "type": "line",
    "layout": {
      "line-cap": "round",
      "line-join": "round",
      "line-miter-limit": 2,
      "line-round-limit": 1
    },
    "source": {
      "id": "mapbox.mapbox-streets-v6-dev",
      "source-layer": "waterway"
    },
    "paint": {
      "line-opacity": 0.9,
      "line-color": [0, 0.48, 0.78, 0.9],
      "line-width": 1.25
    }
  },
  "properties": {
    "class": "river",
    "osm_id": 93380892,
    "type": "river"
  },
  "extent": 4096,
  "type": 2
}

Some questions:

  • Calculated paint props return premultiplied alpha values. Should this remain true for featuresAt or since it's more of an externally facing API should we convert to normal RGBA decimal?
  • The original intent of this API was for source inspection/tile statistics I think which is why it had things like extent and type (I can only assume this is geometry type…??) — should these be removed or are they still useful for something?

@jfirebaugh
Copy link
Contributor

Nice. $type values should be Point, LineString or Polygon (like in filters). It's kind of odd to return premultiplied values but probably fine for now. Let's remove extent and type. What does it look like with {geometry: true} option? Maybe this should be a GeoJSON object.

@lbud
Copy link
Contributor Author

lbud commented Dec 13, 2014

Ah good catch, grabbed the wrong type — thanks!

With {geometry: true}: this is a bit hard to make sense of. I'm not sure what the use case for this format is…?

{
  "$type": "LineString",
  "layer": {
    "id": "road",
    "type": "line",
    "layout": {
      "line-cap": "butt",
      "line-join": "miter",
      "line-miter-limit": 2,
      "line-round-limit": 1
    },
    "source": {
      "id": "mapbox.mapbox-streets-v6-dev",
      "source-layer": "road"
    },
    "paint": {
      "line-color": [
        0.78,
        0,
        0,
        0.78
      ],
      "line-dasharray": [
        3.5,
        2
      ],
      "line-translate": [
        1.75,
        -2.25
      ],
      "line-opacity": 0.78,
      "line-width": 2.5,
      "line-gap-width": 0.25
    }
  },
  "_geometry": [
    [
      {
        "x": 1036,
        "y": 2998
      },
      {
        "x": 1102,
        "y": 3006
      },
      {
        "x": 1145,
        "y": 3002
      },
      {
        "x": 1188,
        "y": 2987
      },
      {
        "x": 1253,
        "y": 2957
      },
      {
        "x": 1301,
        "y": 2924
      },
      {
        "x": 1345,
        "y": 2880
      },
      {
        "x": 1381,
        "y": 2829
      },
      {
        "x": 1411,
        "y": 2769
      },
      {
        "x": 1424,
        "y": 2712
      },
      {
        "x": 1428,
        "y": 2654
      },
      {
        "x": 1423,
        "y": 2583
      },
      {
        "x": 1335,
        "y": 2199
      },
      {
        "x": 1322,
        "y": 2135
      },
      {
        "x": 1320,
        "y": 2086
      },
      {
        "x": 1320,
        "y": 2044
      },
      {
        "x": 1329,
        "y": 1999
      },
      {
        "x": 1336,
        "y": 1979
      },
      {
        "x": 1343,
        "y": 1958
      },
      {
        "x": 1385,
        "y": 1875
      },
      {
        "x": 1400,
        "y": 1854
      },
      {
        "x": 1453,
        "y": 1814
      },
      {
        "x": 1545,
        "y": 1753
      },
      {
        "x": 1649,
        "y": 1723
      },
      {
        "x": 1739,
        "y": 1711
      },
      {
        "x": 1869,
        "y": 1715
      },
      {
        "x": 1915,
        "y": 1717
      },
      {
        "x": 2135,
        "y": 1741
      },
      {
        "x": 2309,
        "y": 1783
      },
      {
        "x": 2499,
        "y": 1841
      },
      {
        "x": 2657,
        "y": 1901
      },
      {
        "x": 2827,
        "y": 1993
      },
      {
        "x": 3117,
        "y": 2173
      },
      {
        "x": 3234,
        "y": 2243
      }
    ]
  ]
}

@lbud lbud mentioned this pull request Dec 15, 2014
Lauren Budorick and others added 3 commits December 16, 2014 14:03
* layer information
* source information
* layout properties
* calculated paint properties

Fixes #876
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

Successfully merging this pull request may close these issues.

2 participants