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

Add MultiPolygon support to Query #866

Merged
merged 2 commits into from
Oct 18, 2016
Merged

Add MultiPolygon support to Query #866

merged 2 commits into from
Oct 18, 2016

Conversation

whyvez
Copy link
Contributor

@whyvez whyvez commented Oct 12, 2016

see: #865

@jgravois
Copy link
Contributor

the error Travis is reporting is coming straight from the linter.

/home/travis/build/Esri/esri-leaflet/src/Tasks/Query.js
214:136  error  There should be no spaces inside this paren

@jgravois
Copy link
Contributor

jgravois commented Oct 12, 2016

you've definitely unearthed some working MultiPolygon query support. very cool!

var holeOverCatalina = {
  "type": "MultiPolygon",
  "coordinates": [
    [[[-118.035, 33.625], [-118.892, 33.625], [-118.892, 33.139], [-118.035, 33.139],  [-118.035, 33.625]]],
    [[[-118.135, 33.525], [-118.792, 33.525], [-118.792, 33.239], [-118.135, 33.239], [-118.135, 33.525]]]
  ]
}

L.esri.query({
  url:'http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3'
})
  .intersects(holeOverCatalina)
  .run(function (err, res, raw) {
    console.log(res.features.length); // returns 0 features (as it should)
  })

to do:

  • fix the linter error
  • update the warning immediately below to acknowledge that the new geometry type is a valid input
  • include a new unit test in spec/Tasks/QuerySpec.js like the one below
var rawMultiPolygon = {
  'type': 'MultiPolygon',
  'coordinates': [
    [[[-97, 39], [-97, 41], [-94, 41], [-94, 39], [-97, 39]]],
    [[[-96, 39.5], [-96, 40.5], [-95, 40.5], [-95, 39.5], [-96, 39.5]]]
  ]
};

it('should query features within a geojson multipolygon geometry', function (done) {
  server.respondWith('GET', featureLayerUrl + 'query?returnGeometry=true&where=1%3D1&outSr=4326&outFields=*&inSr=4326&geometry=%7B%22rings%22%3A%5B%5B%5B-97%2C39%5D%2C%5B-97%2C41%5D%2C%5B-94%2C41%5D%2C%5B-94%2C39%5D%2C%5B-97%2C39%5D%5D%2C%5B%5B-96%2C39.5%5D%2C%5B-96%2C40.5%5D%2C%5B-95%2C40.5%5D%2C%5B-95%2C39.5%5D%2C%5B-96%2C39.5%5D%5D%5D%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&geometryType=esriGeometryPolygon&spatialRel=esriSpatialRelContains&f=json', JSON.stringify(sampleQueryResponse));

  task.within(rawMultiPolygon).run(function (error, featureCollection, raw) {
    expect(featureCollection).to.deep.equal(sampleFeatureCollection);
    expect(raw).to.deep.equal(sampleQueryResponse);
    done();
  });

  server.respond();
});

if you're not up for laying down the additional changes, i can chuck them in after merging.

@whyvez
Copy link
Contributor Author

whyvez commented Oct 18, 2016

@jgravois OK will do. Thanks for the lo down.

@jgravois jgravois merged commit 91cc90b into Esri:master Oct 18, 2016
@jgravois
Copy link
Contributor

awesome. thanks again!

jgravois pushed a commit to jgravois/esri-leaflet that referenced this pull request Apr 23, 2022
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