1.0.0 • Published 2 years ago

query-all-features v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Query All Features

npm

Query all features of an ArcGIS Feature Service

This package calls queryFeatures multiple times until it gets all the features.

Quick Start

npm install query-all-features

Then:

import { queryAllFeatures } from "query-all-features";

queryAllFeatures(
    {
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
    }
).then((results) => {
    console.log('results', results);
}, (err) => {
    console.error('err', err);
});

API Reference

queryAllFeatures

Query a feature service, repeatedly paging through the results to get all the features.

Parameters

ParameterTypeNotes
requestOptionsIQueryFeaturesOptionsThis is the same input object that you would pass into ArcGIS REST JS queryFeatures.
additionalOptionsIQueryFeaturesAllAdditionalOptionsAdditional options specific to this module. See table below.
IQueryFeaturesAllAdditionalOptions
ParameterTypeNotes
pageBy (optional)numberHow many records to request from the service at a time. By default, the service info will be checked to find the maxRecordCount of the service, and that will be used as the pageBy value. If this pageBy value is provided, that additional request will not be made.
import { queryAllFeatures } from "query-all-features";

queryAllFeatures(
    {
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
    }, { 
        pageBy: 100
    }
).then((results) => {
    console.log('results', results);
}, (err) => {
    console.error('err', err);
});

Returns

A Promise that will resolve with the same query response as queryFeatures.

Usage

Node JS

npm install query-all-features

Then:

const { queryAllFeatures } = require("query-all-features");

queryAllFeatures({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"}).then((results) => {
    console.log('results', results);
}, (err) => {
    console.error('err', err);
});

Browser - ES Modules

Distributed as an ES module which should work "out-of-the-box" with most popular module bundlers. See "Quick Start" above.

Browser - ES Modules via CDN

<script type="module">
    import { queryAllFeatures } from "https://cdn.skypack.dev/query-all-features";

    queryAllFeatures({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"}).then((results) => {
        console.log('results', results);
    }, (err) => {
        console.error('err', err);
    });
</script>

Example in action

Browser - Script tag via UMD CDN

<!-- arcgis-rest-request and arcgis-rest-feature-service are dependencies: -->
<script src="https://unpkg.com/@esri/arcgis-rest-request@4"></script>
<script src="https://unpkg.com/@esri/arcgis-rest-feature-service@4"></script>
<script src="https://unpkg.com/query-all-features"></script>

<script>
    queryAllFeatures.queryAllFeatures({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"}).then((results) => {
        console.log('results', results);
    }, (err) => {
        console.log('err', err);
    });
</script>

Example in action

License

Copyright 2022 Gavin Rehkemper

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

1.0.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago