fetch
- Description:
Module for fetching and processing FEMA flood data.
- Source:
Methods
(async, static) fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) → {Promise.<object>}
- Description:
Fetches data for a given PIN (Parcel Identification Number) using a specified schema and geometry. Processes the fetched geometry to calculate centroid, generate attributes, and apply offsets.
- Source:
Example
const result = await fetchDataForPin(
"Horry",
"123456",
"https://example.com/api",
"4326",
schemaKeys,
"parcels"
);
console.log(result.features);
Parameters:
Name | Type | Description |
---|---|---|
county |
string | The name of the county for the data request. |
pin |
string | The Parcel Identification Number (PIN) to fetch data for. |
baseUrl |
string | The base URL for the API endpoint. |
spatialReference |
string | The spatial reference (e.g., EPSG code) for geometry transformation. |
schema |
SchemaKeys | The schema defining the keys for the data attributes. |
layer |
string | The layer name for categorization. |
Throws:
-
Throws an error if the data fetching or processing fails.
- Type
- Error
Returns:
A promise resolving to the fetched and processed data, or an error object.
- Type
- Promise.<object>
(async, static) fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) → {Promise.<object>}
- Description:
Fetches NGS data based on user-provided bounding box and spatial reference.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
xmin |
number | Minimum X coordinate of the bounding box. |
ymin |
number | Minimum Y coordinate of the bounding box. |
xmax |
number | Maximum X coordinate of the bounding box. |
ymax |
number | Maximum Y coordinate of the bounding box. |
urlString |
string | The base URL for the ESRI service. |
spatialReference |
string | The spatial reference for the bounding box. |
Throws:
Will throw an error if the fetch fails or if there are response issues.
Returns:
The fetched NGS data, filtered by attributes and geometry.
- Type
- Promise.<object>
(async, static) fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) → {Promise.<FetchParcelResult>}
- Description:
Fetches parcel data based on a user-provided bounding box geometry. Converts the geometry into a queryable format and processes the response to extract parcel features, centroids, and attributes.
- Source:
Example
const result = await fetchParcelByPolygon(
"Horry",
"https://example.com/api/query",
"4326",
{ rings: [[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]] },
schemaKeys,
"parcels"
);
console.log(result.features);
Parameters:
Name | Type | Description |
---|---|---|
county |
string | The name of the county for which data is being fetched. |
urlString |
string | The URL endpoint for querying parcel data. |
spatialReference |
string | The spatial reference system (e.g., EPSG code). |
geometry |
object | Geometry object representing the area of interest. |
schema |
SchemaKeys | The schema defining keys for extracting parcel attributes. |
layer |
string | The layer name for categorizing the returned features. |
Throws:
-
Throws an error if data fetching or processing fails.
- Type
- Error
Returns:
A promise resolving to an object containing processed parcel features.
- Type
- Promise.<FetchParcelResult>
(async, static) fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) → {Promise.<object>}
- Description:
Fetches parcel data based on a user-provided bounding box and spatial reference. Clips the parcel geometry to the specified bounding box and generates attributes for each parcel.
- Source:
Example
const parcels = await fetchParcelDataByBbox(
-80.0,
30.0,
-79.0,
31.0,
"https://example.com/api",
"4326",
"Horry",
schemaKeys,
"parcel",
"land"
);
console.log(parcels.features);
Parameters:
Name | Type | Description |
---|---|---|
xmin |
number | The minimum x-coordinate of the bounding box. |
ymin |
number | The minimum y-coordinate of the bounding box. |
xmax |
number | The maximum x-coordinate of the bounding box. |
ymax |
number | The maximum y-coordinate of the bounding box. |
urlString |
string | The URL endpoint for querying parcel data. |
spatialReference |
string | The spatial reference system (e.g., EPSG code). |
county |
string | The county name for which data is being fetched. |
schema |
SchemaKeys | Schema object defining attributes for parcel data. |
type |
string | The type of data being fetched (e.g., "parcel"). |
layer |
string | The layer name for categorizing the data. |
Throws:
-
Throws an error if data fetching or processing fails.
- Type
- Error
Returns:
A promise resolving to an object containing clipped parcel features.
- Type
- Promise.<object>
(async, static) fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) → {Promise.<object>}
- Description:
Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.
- Source:
Example
const result = await fetchZoningByPost(
"Horry",
"https://example.com/api",
"4326",
{ rings: [[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]] },
schemaKeys,
"zoning"
);
console.log(result.features);
Parameters:
Name | Type | Description |
---|---|---|
county |
string | Name of the county. |
urlString |
string | URL endpoint for querying zoning data. |
spatialReference |
string | The spatial reference system (e.g., EPSG code). |
geometry |
object | Geometry object representing the area of interest. |
schema |
SchemaKeys | Schema defining attributes to extract. |
layer |
string | The layer name for categorizing the data. |
Throws:
-
Throws an error if the request or processing fails.
- Type
- Error
Returns:
A promise resolving to an object containing processed zoning features.
- Type
- Promise.<object>
(static) flattenGeometryRings(geometry) → {object}
- Description:
Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.
- Source:
Example
const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]
Parameters:
Name | Type | Description |
---|---|---|
geometry |
object | Geometry object containing rings or paths. |
Returns:
A geometry object with flattened coordinates.
- Type
- object
(async, static) floodFetch(county, urlString, spatialReference, geometry, schema, layer) → {Promise.<object>}
- Description:
Fetches FEMA flood data based on user-provided geometry and additional parameters.
- Source:
Example
const data = await fetchFloodByPost(
"Horry",
"https://example.com/floodData",
"4326",
{ rings: [[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]] },
schemaKeys,
"floodLayer"
);
console.log(data.features);
Parameters:
Name | Type | Description |
---|---|---|
county |
string | The name of the county for which data is fetched. |
urlString |
string | The URL endpoint for flood data queries. |
spatialReference |
string | The spatial reference system (e.g., EPSG code). |
geometry |
object | Geometry object representing the area of interest. |
schema |
SchemaKeys | The schema defining attributes to extract. |
layer |
string | The layer name for categorization. |
Throws:
-
Throws an error if data fetching or processing fails.
- Type
- Error
Returns:
A promise resolving to an object containing features with geometry intersections and attributes.
- Type
- Promise.<object>
(static) formatFemaFloodZoneLabels(attributes) → {Object}
- Description:
Formats FEMA flood zone labels based on attributes.
- Source:
Example
const attributes = {
FLD_ZONE: "X",
ZONE_SUBTY: "0.2 PCT ANNUAL CHANCE FLOOD HAZARD",
STATIC_BFE: -9999
};
const label = formatFemaFloodZoneLabels(attributes);
console.log(label.FLD_ZONE); // "X-SHADED"
Parameters:
Name | Type | Description |
---|---|---|
attributes |
object | Attributes containing flood zone information. |
Returns:
An object with the formatted flood zone label.
- Type
- Object
(static) offsetPolygon(polygonCoords, offsetDistance, spatialReference) → {object}
- Description:
Offsets a polygon by a specified distance and reprojects coordinates.
- Source:
Example
const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);
Parameters:
Name | Type | Description |
---|---|---|
polygonCoords |
Array.<Array.<Array.<number>>> | Coordinates of the polygon to offset. |
offsetDistance |
number | The distance to offset the polygon. |
spatialReference |
string | The spatial reference system (e.g., EPSG code). |
Throws:
-
Throws an error if the offset polygon is undefined.
- Type
- Error
Returns:
A GeoJSON Polygon object representing the offset polygon.
- Type
- object
(static) parseGeometryBox(bbox) → {Object}
- Description:
Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.
- Source:
Example
const bbox = parseGeometryBox("-80.0,30.0,-79.0,31.0");
console.log(bbox); // { xmin: -80.0, ymin: 30.0, xmax: -79.0, ymax: 31.0 }
Parameters:
Name | Type | Description |
---|---|---|
bbox |
string | The bounding box string in the format "xmin,ymin,xmax,ymax". |
Throws:
-
Throws an error if the bounding box string is invalid.
- Type
- Error
Returns:
An object with numeric coordinates for the bounding box.
- Type
- Object