Modules

config/proj4-config

Exports the configured proj4 library for use in other parts of the application. Allows transformation of coordinates using the defined custom projections.

Objects

config : object

Configuration and utility functions for managing MongoDB connections.

config : object

Configuration for custom projection definitions using the proj4 library.

config : object

Configuration for Swagger documentation generation using swagger-jsdoc.

fetch : object

Module for fetching and processing FEMA flood data.

fetch : object

Namespace for GIS Cad Connector functions and utilities.

fetch : object

Utility functions and modules for processing geometry, formatting, and fetching data.

fetch : object

Fetch utilities for handling parcel data queries and geometry operations.

fetch : object

Utilities for fetching and processing parcel data.

fetch : object

Functions for fetching and processing zoning data.

app : object

Initializes and configures the Express application. Sets up middleware, routes, and error handling for the application.

routes : object

This module contains routes for administrative database operations.

utils : object

Utility functions for processing data.

geometryFilter : object

Utility functions for filtering geometry coordinates based on bounding boxes.

geometryUtils : object

Utility functions for fetching, converting, and buffering geometry data.

geometryUtils : object

Utilities for geometric calculations, including centroid calculation and polyline conversion.

utils : object

Utility functions for geometric operations, including bounding box checks and path splitting.

Constants

endpointsFiles : Array.<string>

List of endpoint files to generate Swagger documentation for.

doc : SwaggerDoc

Swagger documentation configuration object.

app : express.Application
PORT : number | string

The port on which the server will run.

adminRouter : Router

Router for admin-related database operations.

client : MongoClient

MongoDB client instance used to connect to the database.

agent : https.Agent

HTTPS agent for handling requests with legacy SSL support.

router : express.Router

Express router for handling county-based parcel data requests.

router : *

Description placeholder

WKID_3361 : string

${1:Description placeholder}

FIPS_3900 : string

${1:Description placeholder}

agent : https.Agent

HTTPS agent for handling requests with legacy SSL support.

Functions

fetchCountySchema(dbName, county)

Fetches the schema for a specific county from a MongoDB database.

generateMarkdown(swaggerData)string

Converts Swagger documentation JSON into a Markdown string for use in a README file.

authenticateToken(req, res, next)

Description placeholder

fetchGisFolders(baseUrl)Promise.<Array.<string>>

Fetches GIS folders from a given base URL.

fetchGisServices(baseUrl)Promise.<Array.<string>>

Fetches GIS services directly from a given base URL.

fetchAllGis(baseUrl)Promise.<Array.<string>>

Fetches both GIS folders and services and combines their URLs.

dataFetch(baseUrl)Promise.<Array.<any>>

Fetches all data layers from a GIS base URL.

isPointInsidePolygon(point, polygon)

Determines if a given point is inside a polygon.

This function uses the ray-casting algorithm to determine if the point is inside the polygon. It works by drawing a horizontal line from the point to the outside of the polygon and counting how many times the line intersects with the edges of the polygon. If the number of intersections is odd, the point is inside the polygon. If even, the point is outside.

doSegmentsIntersect(p1, p2, q1, q2)

Determines if two line segments intersect and returns the intersection point if they do.

splitPathAtIntersection(polygon1, polygon2)

Splits the path of the first polygon at intersections with the second polygon and merges the resulting paths.

offsetPolygon(polygonCoords, offsetDistance, spatialReference)

Offsets a polygon by a given distance and reprojects the coordinates.

Typedefs

SwaggerInfo : Object
SwaggerServer : Object
SwaggerDoc : Object

config/proj4-config

Exports the configured proj4 library for use in other parts of the application. Allows transformation of coordinates using the defined custom projections.

Example

import proj4 from './proj4Config';
const coords = proj4('EPSG:2273', 'EPSG:4326', [1000, 2000]);
console.log(coords);

config : object

Configuration and utility functions for managing MongoDB connections.

Kind: global namespace

config.client : MongoClient | null

MongoDB client instance. Initialized as null and set upon first connection.

Kind: static property of config

config.clientPromise : Promise.<MongoClient> | null

Promise for the MongoDB client instance. Ensures only one connection is created.

Kind: static property of config

config.mongoUrl : string

MongoDB connection URI from the environment variable MONGO_URI. Throws an error if not set.

Kind: static constant of config

config.swaggerOptions : swaggerJsdoc.Options

Swagger configuration options for generating the OpenAPI documentation. Defines metadata, servers, and paths for the API documentation.

Kind: static constant of config
Properties

Name Type Description
definition object OpenAPI specification details.
definition.openapi string Specifies the OpenAPI version.
definition.info object Contains metadata about the API.
definition.info.title string Title of the API documentation.
definition.info.version string Version of the API.
definition.info.description string A short description of the API.
definition.host string The host URL for the API.
definition.servers Array.<object> List of server objects for API interaction.
apis string Glob pattern to locate route files for Swagger documentation.

Example

const swaggerOptions = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: 'My API',
      version: '1.0.0',
      description: 'API documentation',
    },
    servers: [{ url: 'http://localhost:5000' }],
  },
  apis: ['./src/routes/*.ts'],
};

config.swaggerSpec : object

Generates the Swagger specification using the provided options. This specification can be used to configure Swagger-UI or similar tools.

Kind: static constant of config
Properties

Name Type Description
paths object Contains the paths and endpoints documented in your API.
components object Holds reusable components such as schemas or responses.

Example

import swaggerSpec from './swaggerConfig';
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));

config.getClient() ⇒ Promise.<MongoClient>

Retrieves the MongoDB client instance, connecting if necessary. Ensures only one connection is created across multiple calls.

Kind: static method of config
Returns: Promise.<MongoClient> - Resolves to the MongoDB client instance.
Throws:

  • Error Throws an error if the client cannot be connected.

Example

const client = await getClient();
console.log(client.isConnected());

config.connectToDatabase([dbName]) ⇒ Promise.<Db>

Connects to the specified database using the MongoDB client. If no database name is provided, the default database is used.

Kind: static method of config
Returns: Promise.<Db> - Resolves to the database instance.
Throws:

  • Error Throws an error if the database connection fails.
Param Type Description
[dbName] string Name of the database to connect to. Optional.

Example

const db = await connectToDatabase("myDatabase");
console.log(db.databaseName);

config.closeClient() ⇒ Promise.<void>

Closes the MongoDB client connection. Ensures the client and its promise are reset to avoid stale connections.

Kind: static method of config
Returns: Promise.<void> - Resolves when the client is successfully closed.
Throws:

  • Error Throws an error if the client fails to close.

Example

await closeClient();
console.log('Connection closed');

config : object

Configuration for custom projection definitions using the proj4 library.

Kind: global namespace

config.client : MongoClient | null

MongoDB client instance. Initialized as null and set upon first connection.

Kind: static property of config

config.clientPromise : Promise.<MongoClient> | null

Promise for the MongoDB client instance. Ensures only one connection is created.

Kind: static property of config

config.mongoUrl : string

MongoDB connection URI from the environment variable MONGO_URI. Throws an error if not set.

Kind: static constant of config

config.swaggerOptions : swaggerJsdoc.Options

Swagger configuration options for generating the OpenAPI documentation. Defines metadata, servers, and paths for the API documentation.

Kind: static constant of config
Properties

Name Type Description
definition object OpenAPI specification details.
definition.openapi string Specifies the OpenAPI version.
definition.info object Contains metadata about the API.
definition.info.title string Title of the API documentation.
definition.info.version string Version of the API.
definition.info.description string A short description of the API.
definition.host string The host URL for the API.
definition.servers Array.<object> List of server objects for API interaction.
apis string Glob pattern to locate route files for Swagger documentation.

Example

const swaggerOptions = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: 'My API',
      version: '1.0.0',
      description: 'API documentation',
    },
    servers: [{ url: 'http://localhost:5000' }],
  },
  apis: ['./src/routes/*.ts'],
};

config.swaggerSpec : object

Generates the Swagger specification using the provided options. This specification can be used to configure Swagger-UI or similar tools.

Kind: static constant of config
Properties

Name Type Description
paths object Contains the paths and endpoints documented in your API.
components object Holds reusable components such as schemas or responses.

Example

import swaggerSpec from './swaggerConfig';
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));

config.getClient() ⇒ Promise.<MongoClient>

Retrieves the MongoDB client instance, connecting if necessary. Ensures only one connection is created across multiple calls.

Kind: static method of config
Returns: Promise.<MongoClient> - Resolves to the MongoDB client instance.
Throws:

  • Error Throws an error if the client cannot be connected.

Example

const client = await getClient();
console.log(client.isConnected());

config.connectToDatabase([dbName]) ⇒ Promise.<Db>

Connects to the specified database using the MongoDB client. If no database name is provided, the default database is used.

Kind: static method of config
Returns: Promise.<Db> - Resolves to the database instance.
Throws:

  • Error Throws an error if the database connection fails.
Param Type Description
[dbName] string Name of the database to connect to. Optional.

Example

const db = await connectToDatabase("myDatabase");
console.log(db.databaseName);

config.closeClient() ⇒ Promise.<void>

Closes the MongoDB client connection. Ensures the client and its promise are reset to avoid stale connections.

Kind: static method of config
Returns: Promise.<void> - Resolves when the client is successfully closed.
Throws:

  • Error Throws an error if the client fails to close.

Example

await closeClient();
console.log('Connection closed');

config : object

Configuration for Swagger documentation generation using swagger-jsdoc.

Kind: global namespace

config.client : MongoClient | null

MongoDB client instance. Initialized as null and set upon first connection.

Kind: static property of config

config.clientPromise : Promise.<MongoClient> | null

Promise for the MongoDB client instance. Ensures only one connection is created.

Kind: static property of config

config.mongoUrl : string

MongoDB connection URI from the environment variable MONGO_URI. Throws an error if not set.

Kind: static constant of config

config.swaggerOptions : swaggerJsdoc.Options

Swagger configuration options for generating the OpenAPI documentation. Defines metadata, servers, and paths for the API documentation.

Kind: static constant of config
Properties

Name Type Description
definition object OpenAPI specification details.
definition.openapi string Specifies the OpenAPI version.
definition.info object Contains metadata about the API.
definition.info.title string Title of the API documentation.
definition.info.version string Version of the API.
definition.info.description string A short description of the API.
definition.host string The host URL for the API.
definition.servers Array.<object> List of server objects for API interaction.
apis string Glob pattern to locate route files for Swagger documentation.

Example

const swaggerOptions = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: 'My API',
      version: '1.0.0',
      description: 'API documentation',
    },
    servers: [{ url: 'http://localhost:5000' }],
  },
  apis: ['./src/routes/*.ts'],
};

config.swaggerSpec : object

Generates the Swagger specification using the provided options. This specification can be used to configure Swagger-UI or similar tools.

Kind: static constant of config
Properties

Name Type Description
paths object Contains the paths and endpoints documented in your API.
components object Holds reusable components such as schemas or responses.

Example

import swaggerSpec from './swaggerConfig';
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));

config.getClient() ⇒ Promise.<MongoClient>

Retrieves the MongoDB client instance, connecting if necessary. Ensures only one connection is created across multiple calls.

Kind: static method of config
Returns: Promise.<MongoClient> - Resolves to the MongoDB client instance.
Throws:

  • Error Throws an error if the client cannot be connected.

Example

const client = await getClient();
console.log(client.isConnected());

config.connectToDatabase([dbName]) ⇒ Promise.<Db>

Connects to the specified database using the MongoDB client. If no database name is provided, the default database is used.

Kind: static method of config
Returns: Promise.<Db> - Resolves to the database instance.
Throws:

  • Error Throws an error if the database connection fails.
Param Type Description
[dbName] string Name of the database to connect to. Optional.

Example

const db = await connectToDatabase("myDatabase");
console.log(db.databaseName);

config.closeClient() ⇒ Promise.<void>

Closes the MongoDB client connection. Ensures the client and its promise are reset to avoid stale connections.

Kind: static method of config
Returns: Promise.<void> - Resolves when the client is successfully closed.
Throws:

  • Error Throws an error if the client fails to close.

Example

await closeClient();
console.log('Connection closed');

fetch : object

Module for fetching and processing FEMA flood data.

Kind: global namespace

fetch.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.fetchFloodByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches FEMA flood data based on user-provided geometry and additional parameters.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing features with geometry intersections and attributes.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Helper function to flatten geometry rings. Flattens nested coordinate arrays to simplify processing.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing coordinates.

Example

const geometry = flattenGeometryRings({
  coordinates: [[[0, 0], [10, 0]], [[10, 10], [0, 10]]]
});
console.log(geometry.coordinates); // [[0, 0], [10, 0], [10, 10], [0, 10]]

fetch.formatFemaFloodZoneLabels(attributes) ⇒ Object

Formats FEMA flood zone labels based on attributes.

Kind: static method of fetch
Returns: Object - An object with the formatted flood zone label.

Param Type Description
attributes object Attributes containing flood zone information.

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"

fetch.fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) ⇒ Promise.<object>

Fetches NGS data based on user-provided bounding box and spatial reference.

Kind: static method of fetch
Returns: Promise.<object> - The fetched NGS data, filtered by attributes and geometry.
Throws:

  • Will throw an error if the fetch fails or if there are response issues.
Param 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.

fetch.fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to the fetched and processed data, or an error object.
Throws:

  • Error Throws an error if the data fetching or processing fails.
Param 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.

Example

const result = await fetchDataForPin(
  "Horry",
  "123456",
  "https://example.com/api",
  "4326",
  schemaKeys,
  "parcels"
);
console.log(result.features);

fetch.fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<FetchParcelResult>

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.

Kind: static method of fetch
Returns: Promise.<FetchParcelResult> - A promise resolving to an object containing processed parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing clipped parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.parseGeometryBox(bbox) ⇒ Object

Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.

Kind: static method of fetch
Returns: Object - An object with numeric coordinates for the bounding box.
Throws:

  • Error Throws an error if the bounding box string is invalid.
Param Type Description
bbox string The bounding box string in the format "xmin,ymin,xmax,ymax".

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 }

fetch.fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing processed zoning features.
Throws:

  • Error Throws an error if the request or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing rings or paths.

Example

const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]

fetch.offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒ object

Offsets a polygon by a specified distance and reprojects coordinates.

Kind: static method of fetch
Returns: object - A GeoJSON Polygon object representing the offset polygon.
Throws:

  • Error Throws an error if the offset polygon is undefined.
Param 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).

Example

const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);

fetch : object

Namespace for GIS Cad Connector functions and utilities.

Kind: global namespace

fetch.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.fetchFloodByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches FEMA flood data based on user-provided geometry and additional parameters.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing features with geometry intersections and attributes.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Helper function to flatten geometry rings. Flattens nested coordinate arrays to simplify processing.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing coordinates.

Example

const geometry = flattenGeometryRings({
  coordinates: [[[0, 0], [10, 0]], [[10, 10], [0, 10]]]
});
console.log(geometry.coordinates); // [[0, 0], [10, 0], [10, 10], [0, 10]]

fetch.formatFemaFloodZoneLabels(attributes) ⇒ Object

Formats FEMA flood zone labels based on attributes.

Kind: static method of fetch
Returns: Object - An object with the formatted flood zone label.

Param Type Description
attributes object Attributes containing flood zone information.

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"

fetch.fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) ⇒ Promise.<object>

Fetches NGS data based on user-provided bounding box and spatial reference.

Kind: static method of fetch
Returns: Promise.<object> - The fetched NGS data, filtered by attributes and geometry.
Throws:

  • Will throw an error if the fetch fails or if there are response issues.
Param 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.

fetch.fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to the fetched and processed data, or an error object.
Throws:

  • Error Throws an error if the data fetching or processing fails.
Param 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.

Example

const result = await fetchDataForPin(
  "Horry",
  "123456",
  "https://example.com/api",
  "4326",
  schemaKeys,
  "parcels"
);
console.log(result.features);

fetch.fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<FetchParcelResult>

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.

Kind: static method of fetch
Returns: Promise.<FetchParcelResult> - A promise resolving to an object containing processed parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing clipped parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.parseGeometryBox(bbox) ⇒ Object

Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.

Kind: static method of fetch
Returns: Object - An object with numeric coordinates for the bounding box.
Throws:

  • Error Throws an error if the bounding box string is invalid.
Param Type Description
bbox string The bounding box string in the format "xmin,ymin,xmax,ymax".

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 }

fetch.fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing processed zoning features.
Throws:

  • Error Throws an error if the request or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing rings or paths.

Example

const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]

fetch.offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒ object

Offsets a polygon by a specified distance and reprojects coordinates.

Kind: static method of fetch
Returns: object - A GeoJSON Polygon object representing the offset polygon.
Throws:

  • Error Throws an error if the offset polygon is undefined.
Param 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).

Example

const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);

fetch : object

Utility functions and modules for processing geometry, formatting, and fetching data.

Kind: global namespace

fetch.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.fetchFloodByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches FEMA flood data based on user-provided geometry and additional parameters.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing features with geometry intersections and attributes.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Helper function to flatten geometry rings. Flattens nested coordinate arrays to simplify processing.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing coordinates.

Example

const geometry = flattenGeometryRings({
  coordinates: [[[0, 0], [10, 0]], [[10, 10], [0, 10]]]
});
console.log(geometry.coordinates); // [[0, 0], [10, 0], [10, 10], [0, 10]]

fetch.formatFemaFloodZoneLabels(attributes) ⇒ Object

Formats FEMA flood zone labels based on attributes.

Kind: static method of fetch
Returns: Object - An object with the formatted flood zone label.

Param Type Description
attributes object Attributes containing flood zone information.

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"

fetch.fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) ⇒ Promise.<object>

Fetches NGS data based on user-provided bounding box and spatial reference.

Kind: static method of fetch
Returns: Promise.<object> - The fetched NGS data, filtered by attributes and geometry.
Throws:

  • Will throw an error if the fetch fails or if there are response issues.
Param 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.

fetch.fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to the fetched and processed data, or an error object.
Throws:

  • Error Throws an error if the data fetching or processing fails.
Param 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.

Example

const result = await fetchDataForPin(
  "Horry",
  "123456",
  "https://example.com/api",
  "4326",
  schemaKeys,
  "parcels"
);
console.log(result.features);

fetch.fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<FetchParcelResult>

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.

Kind: static method of fetch
Returns: Promise.<FetchParcelResult> - A promise resolving to an object containing processed parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing clipped parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.parseGeometryBox(bbox) ⇒ Object

Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.

Kind: static method of fetch
Returns: Object - An object with numeric coordinates for the bounding box.
Throws:

  • Error Throws an error if the bounding box string is invalid.
Param Type Description
bbox string The bounding box string in the format "xmin,ymin,xmax,ymax".

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 }

fetch.fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing processed zoning features.
Throws:

  • Error Throws an error if the request or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing rings or paths.

Example

const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]

fetch.offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒ object

Offsets a polygon by a specified distance and reprojects coordinates.

Kind: static method of fetch
Returns: object - A GeoJSON Polygon object representing the offset polygon.
Throws:

  • Error Throws an error if the offset polygon is undefined.
Param 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).

Example

const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);

fetch : object

Fetch utilities for handling parcel data queries and geometry operations.

Kind: global namespace

fetch.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.fetchFloodByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches FEMA flood data based on user-provided geometry and additional parameters.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing features with geometry intersections and attributes.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Helper function to flatten geometry rings. Flattens nested coordinate arrays to simplify processing.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing coordinates.

Example

const geometry = flattenGeometryRings({
  coordinates: [[[0, 0], [10, 0]], [[10, 10], [0, 10]]]
});
console.log(geometry.coordinates); // [[0, 0], [10, 0], [10, 10], [0, 10]]

fetch.formatFemaFloodZoneLabels(attributes) ⇒ Object

Formats FEMA flood zone labels based on attributes.

Kind: static method of fetch
Returns: Object - An object with the formatted flood zone label.

Param Type Description
attributes object Attributes containing flood zone information.

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"

fetch.fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) ⇒ Promise.<object>

Fetches NGS data based on user-provided bounding box and spatial reference.

Kind: static method of fetch
Returns: Promise.<object> - The fetched NGS data, filtered by attributes and geometry.
Throws:

  • Will throw an error if the fetch fails or if there are response issues.
Param 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.

fetch.fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to the fetched and processed data, or an error object.
Throws:

  • Error Throws an error if the data fetching or processing fails.
Param 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.

Example

const result = await fetchDataForPin(
  "Horry",
  "123456",
  "https://example.com/api",
  "4326",
  schemaKeys,
  "parcels"
);
console.log(result.features);

fetch.fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<FetchParcelResult>

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.

Kind: static method of fetch
Returns: Promise.<FetchParcelResult> - A promise resolving to an object containing processed parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing clipped parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.parseGeometryBox(bbox) ⇒ Object

Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.

Kind: static method of fetch
Returns: Object - An object with numeric coordinates for the bounding box.
Throws:

  • Error Throws an error if the bounding box string is invalid.
Param Type Description
bbox string The bounding box string in the format "xmin,ymin,xmax,ymax".

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 }

fetch.fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing processed zoning features.
Throws:

  • Error Throws an error if the request or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing rings or paths.

Example

const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]

fetch.offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒ object

Offsets a polygon by a specified distance and reprojects coordinates.

Kind: static method of fetch
Returns: object - A GeoJSON Polygon object representing the offset polygon.
Throws:

  • Error Throws an error if the offset polygon is undefined.
Param 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).

Example

const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);

fetch : object

Utilities for fetching and processing parcel data.

Kind: global namespace

fetch.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.fetchFloodByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches FEMA flood data based on user-provided geometry and additional parameters.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing features with geometry intersections and attributes.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Helper function to flatten geometry rings. Flattens nested coordinate arrays to simplify processing.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing coordinates.

Example

const geometry = flattenGeometryRings({
  coordinates: [[[0, 0], [10, 0]], [[10, 10], [0, 10]]]
});
console.log(geometry.coordinates); // [[0, 0], [10, 0], [10, 10], [0, 10]]

fetch.formatFemaFloodZoneLabels(attributes) ⇒ Object

Formats FEMA flood zone labels based on attributes.

Kind: static method of fetch
Returns: Object - An object with the formatted flood zone label.

Param Type Description
attributes object Attributes containing flood zone information.

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"

fetch.fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) ⇒ Promise.<object>

Fetches NGS data based on user-provided bounding box and spatial reference.

Kind: static method of fetch
Returns: Promise.<object> - The fetched NGS data, filtered by attributes and geometry.
Throws:

  • Will throw an error if the fetch fails or if there are response issues.
Param 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.

fetch.fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to the fetched and processed data, or an error object.
Throws:

  • Error Throws an error if the data fetching or processing fails.
Param 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.

Example

const result = await fetchDataForPin(
  "Horry",
  "123456",
  "https://example.com/api",
  "4326",
  schemaKeys,
  "parcels"
);
console.log(result.features);

fetch.fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<FetchParcelResult>

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.

Kind: static method of fetch
Returns: Promise.<FetchParcelResult> - A promise resolving to an object containing processed parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing clipped parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.parseGeometryBox(bbox) ⇒ Object

Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.

Kind: static method of fetch
Returns: Object - An object with numeric coordinates for the bounding box.
Throws:

  • Error Throws an error if the bounding box string is invalid.
Param Type Description
bbox string The bounding box string in the format "xmin,ymin,xmax,ymax".

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 }

fetch.fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing processed zoning features.
Throws:

  • Error Throws an error if the request or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing rings or paths.

Example

const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]

fetch.offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒ object

Offsets a polygon by a specified distance and reprojects coordinates.

Kind: static method of fetch
Returns: object - A GeoJSON Polygon object representing the offset polygon.
Throws:

  • Error Throws an error if the offset polygon is undefined.
Param 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).

Example

const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);

fetch : object

Functions for fetching and processing zoning data.

Kind: global namespace

fetch.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for making secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.agent : https.Agent

HTTPS Agent for secure requests with legacy SSL support.

Kind: static constant of fetch

fetch.fetchFloodByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches FEMA flood data based on user-provided geometry and additional parameters.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing features with geometry intersections and attributes.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Helper function to flatten geometry rings. Flattens nested coordinate arrays to simplify processing.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing coordinates.

Example

const geometry = flattenGeometryRings({
  coordinates: [[[0, 0], [10, 0]], [[10, 10], [0, 10]]]
});
console.log(geometry.coordinates); // [[0, 0], [10, 0], [10, 10], [0, 10]]

fetch.formatFemaFloodZoneLabels(attributes) ⇒ Object

Formats FEMA flood zone labels based on attributes.

Kind: static method of fetch
Returns: Object - An object with the formatted flood zone label.

Param Type Description
attributes object Attributes containing flood zone information.

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"

fetch.fetchNGSdataByBox(xmin, ymin, xmax, ymax, urlString, spatialReference) ⇒ Promise.<object>

Fetches NGS data based on user-provided bounding box and spatial reference.

Kind: static method of fetch
Returns: Promise.<object> - The fetched NGS data, filtered by attributes and geometry.
Throws:

  • Will throw an error if the fetch fails or if there are response issues.
Param 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.

fetch.fetchDataForPin(county, pin, baseUrl, spatialReference, schema, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to the fetched and processed data, or an error object.
Throws:

  • Error Throws an error if the data fetching or processing fails.
Param 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.

Example

const result = await fetchDataForPin(
  "Horry",
  "123456",
  "https://example.com/api",
  "4326",
  schemaKeys,
  "parcels"
);
console.log(result.features);

fetch.fetchParcelByPolygon(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<FetchParcelResult>

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.

Kind: static method of fetch
Returns: Promise.<FetchParcelResult> - A promise resolving to an object containing processed parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.fetchParcelDataByBbox(xmin, ymin, xmax, ymax, urlString, spatialReference, county, schema, type, layer) ⇒ Promise.<object>

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.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing clipped parcel features.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param 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.

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);

fetch.parseGeometryBox(bbox) ⇒ Object

Parses a bounding box string into an object with xmin, ymin, xmax, ymax coordinates.

Kind: static method of fetch
Returns: Object - An object with numeric coordinates for the bounding box.
Throws:

  • Error Throws an error if the bounding box string is invalid.
Param Type Description
bbox string The bounding box string in the format "xmin,ymin,xmax,ymax".

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 }

fetch.fetchZoningByPost(county, urlString, spatialReference, geometry, schema, layer) ⇒ Promise.<object>

Fetches zoning data by performing a POST request with user-provided geometry. Processes geometry intersections, offsets, and centroids.

Kind: static method of fetch
Returns: Promise.<object> - A promise resolving to an object containing processed zoning features.
Throws:

  • Error Throws an error if the request or processing fails.
Param 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.

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);

fetch.flattenGeometryRings(geometry) ⇒ object

Flattens geometry rings by removing unnecessary nesting and ensuring valid structure.

Kind: static method of fetch
Returns: object - A geometry object with flattened coordinates.

Param Type Description
geometry object Geometry object containing rings or paths.

Example

const flattened = flattenGeometryRings({ coordinates: [[[0, 0], [10, 0]]] });
console.log(flattened.coordinates); // [[0, 0], [10, 0]]

fetch.offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒ object

Offsets a polygon by a specified distance and reprojects coordinates.

Kind: static method of fetch
Returns: object - A GeoJSON Polygon object representing the offset polygon.
Throws:

  • Error Throws an error if the offset polygon is undefined.
Param 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).

Example

const offset = offsetPolygon([[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], 100, "EPSG:2273");
console.log(offset.geometry.coordinates);

app : object

Initializes and configures the Express application. Sets up middleware, routes, and error handling for the application.

Kind: global namespace

app.cleanup() ⇒ Promise.<void>

Handles cleanup operations on process termination. Closes the MongoDB connection and exits the process.

Kind: static method of app

routes : object

This module contains routes for administrative database operations.

Kind: global namespace

  • routes : object
    • [.GET /admin/databases(req, res)](#routes.GET /admin/databases) ⇒ void
    • [.POST /admin/databases(req, res)](#routes.POST /admin/databases) ⇒ void
    • [.GET /admin/databases/:dbName/collections(req, res)](#routes.GET /admin/databases/_dbName/collections) ⇒ void
    • [.POST /admin/databases/:dbName/collections(req, res)](#routes.POST /admin/databases/_dbName/collections) ⇒ void
    • [.DELETE /admin/databases/:dbName/collections/:collectionName(req, res)](#routes.DELETE /admin/databases/_dbName/collections/_collectionName) ⇒ void
    • [.GET /admin/databases/:dbName/collections/:collectionName/newSchema(req, res)](#routes.GET /admin/databases/_dbName/collections/_collectionName/newSchema) ⇒ void
    • [.POST /admin/databases/:dbName/collections/:collectionName/newSchema(req, res)](#routes.POST /admin/databases/_dbName/collections/_collectionName/newSchema) ⇒ void
    • [.GET /admin/databases/:dbName/collections/:collectionName/schema(req, res)](#routes.GET /admin/databases/_dbName/collections/_collectionName/schema) ⇒ void
    • [.PUT /admin/databases/:dbName/collections/:collectionName/schema(req, res)](#routes.PUT /admin/databases/_dbName/collections/_collectionName/schema) ⇒ void
    • [.POST /admin/databases/:dbName/collections/:collectionName/schema(req, res)](#routes.POST /admin/databases/_dbName/collections/_collectionName/schema) ⇒ void

routes.GET /admin/databases(req, res) ⇒ void

Retrieves a list of all available databases in the MongoDB instance.

Kind: static method of routes
Returns: void - Renders a list of databases or sends an error response.

Param Type Description
req Request Express request object.
res Response Express response object.

Example

// Curl Example:
curl -X GET http://localhost:3000/admin/databases

Example

// Response:
{
  "databases": [
    { "name": "admin", "sizeOnDisk": 8192, "empty": false },
    { "name": "local", "sizeOnDisk": 4096, "empty": false }
  ]
}

routes.POST /admin/databases(req, res) ⇒ void

Creates a new database by providing a name and initializing it with a default collection.

Kind: static method of routes
Returns: void - Sends a success or error response.

Param Type Description
req Request Express request object containing the database name in the body.
res Response Express response object.

Example

// Curl Example:
curl -X POST http://localhost:3000/admin/databases -H "Content-Type: application/json" -d '{"name": "test_db"}'

Example

// Response:
{
  "success": true,
  "message": "Database created successfully",
  "name": "test_db"
}

routes.GET /admin/databases/:dbName/collections(req, res) ⇒ void

Retrieves a list of collections in the specified database.

Kind: static method of routes
Returns: void - Renders a list of collections or sends an error response.

Param Type Description
req Request Express request object containing the database name as a URL parameter.
res Response Express response object.

Example

// Curl Example:
curl -X GET http://localhost:3000/admin/databases/my_database/collections

Example

// Response:
{
  "collections": [
    { "name": "users" },
    { "name": "products" }
  ]
}

routes.POST /admin/databases/:dbName/collections(req, res) ⇒ void

Adds a new collection to the specified database.

Kind: static method of routes
Returns: void - Sends a success or error response.

Param Type Description
req Request Express request object containing the database name as a URL parameter and the collection name in the body.
res Response Express response object.

Example

// Curl Example:
curl -X POST http://localhost:3000/admin/databases/my_database/collections -H "Content-Type: application/json" -d '{"name": "my_collection"}'

Example

// Response:
{
  "success": true,
  "message": "Collection created successfully",
  "redirectUrl": "/databases/my_database/collections/my_collection/newSchema"
}

routes.DELETE /admin/databases/:dbName/collections/:collectionName(req, res) ⇒ void

Deletes a collection in the specified database.

Kind: static method of routes
Returns: void - Sends a success or error response.

Param Type Description
req Request Express request object containing database and collection names as URL parameters.
res Response Express response object.

Example

// Curl Example:
curl -X DELETE http://localhost:3000/admin/databases/my_database/collections/my_collection

Example

// Response:
{
  "success": true,
  "message": "Collection deleted successfully"
}

routes.GET /admin/databases/:dbName/collections/:collectionName/newSchema(req, res) ⇒ void

Retrieves the schema for a collection in the specified database.

Kind: static method of routes
Returns: void - Renders the schema or sends an error response.

Param Type Description
req Request Express request object containing database and collection names as URL parameters.
res Response Express response object.

Example

// Curl Example:
curl -X GET http://localhost:3000/admin/databases/my_database/collections/my_collection/newSchema

Example

// Response:
{
  "dbName": "my_database",
  "collectionName": "my_collection",
  "schema": {
    "field1": "value1",
    "field2": "value2"
  }
}

routes.POST /admin/databases/:dbName/collections/:collectionName/newSchema(req, res) ⇒ void

Updates or creates a schema for the specified MongoDB collection in the database. Ensures proper handling of keys, data types, and dependencies on the available_layers database.

Kind: static method of routes
Returns: void - Redirects to the schema page or renders an error response in case of failure.

Param Type Description
req Request Express request object containing database and collection names as URL parameters, and the schema update details in the body.
res Response Express response object.

Example

// Curl Example:
curl -X POST http://localhost:3000/admin/databases/my_database/collections/my_collection/newSchema \
-H "Content-Type: application/json" \
-d '{
  "keys": {
    "booleans": { "isActive": "true", "isDeleted": "false" },
    "ownerNameKeys": ["ownerName1", "ownerName2"],
    "addressKeys": "addressKey1"
  },
  "baseUrls": {
    "key1": "https://example.com",
    "key2": "https://another.com"
  }
}'

Example

// Response:
HTTP/1.1 302 Found
Location: /databases/my_database/collections/my_collection/schema

routes.GET /admin/databases/:dbName/collections/:collectionName/schema(req, res) ⇒ void

Retrieves the schema for a specific collection in the specified database.

Kind: static method of routes
Returns: void - Renders the schema or sends an error response in case of failure.

Param Type Description
req Request Express request object containing database and collection names as URL parameters.
res Response Express response object.

Example

// Curl Example:
curl -X GET http://localhost:3000/admin/databases/my_database/collections/my_collection/schema

Example

// Response:
{
  "dbName": "my_database",
  "collectionName": "my_collection",
  "schema": {
    "keys": {
      "booleans": { "isActive": true },
      "ownerNameKeys": ["owner1", "owner2"],
      "addressKeys": ["address1"]
    },
    "baseUrls": { "url1": "https://example.com" }
  }
}

routes.PUT /admin/databases/:dbName/collections/:collectionName/schema(req, res) ⇒ void

Updates the schema for a specific collection in the specified database.

Kind: static method of routes
Returns: void - Sends a success message or an error response in case of failure.

Param Type Description
req Request Express request object containing database and collection names as URL parameters and the new schema in the body.
res Response Express response object.

Example

// Curl Example:
curl -X PUT http://localhost:3000/admin/databases/my_database/collections/my_collection/schema \
-H "Content-Type: application/json" \
-d '{
  "keys": {
    "booleans": { "isActive": true },
    "ownerNameKeys": ["owner1"],
    "addressKeys": ["address1"]
  },
  "baseUrls": { "url1": "https://example.com" }
}'

Example

// Response:
{
  "message": "Schema updated successfully"
}

routes.POST /admin/databases/:dbName/collections/:collectionName/schema(req, res) ⇒ void

Updates or creates a schema for the specified collection in the given database. Handles various input validations, merges fields, and manages dependencies on the available_layers database.

Kind: static method of routes
Returns: void - Redirects to the schema page or renders an error response in case of failure.

Param Type Description
req Request Express request object containing database and collection names as URL parameters and the schema update details in the body.
res Response Express response object.

Example

// Curl Example:
curl -X POST http://localhost:3000/admin/databases/my_database/collections/my_collection/schema \
-H "Content-Type: application/json" \
-d '{
  "keys": {
    "booleans": { "isActive": "true", "isArchived": "false" },
    "ownerNameKeys": ["owner1", "owner2"],
    "addressKeys": "address1"
  },
  "baseUrls": {
    "key1": "https://example.com",
    "key2": "https://another.com"
  }
}'

Example

// Response (Redirect):
HTTP/1.1 302 Found
Location: /databases/my_database/collections/my_collection/schema

utils : object

Utility functions for processing data.

Kind: global namespace

utils.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of utils

utils.formatBookPage(input) ⇒ Object

Parses a string to extract the book and page components. The input format should be either part1-part2 or part1 part2.

Kind: static method of utils
Returns: Object - An object containing the parsed book and page values.

Param Type Description
input string The string input containing book and page information.

Example

const { book, page } = formatBookPage("123-456");
console.log(book, page); // "123", "456"

utils.formatTimestampToDate(timestamp) ⇒ string

Converts a timestamp into a human-readable date string in the format MM/DD/YYYY.

Kind: static method of utils
Returns: string - The formatted date string.

Param Type Description
timestamp number The Unix timestamp in milliseconds.

Example

const date = formatTimestampToDate(1672531200000);
console.log(date); // "01/01/2023"

utils.generateAttributes(attributes, schema, spatialReference, county) ⇒

Generates a set of attributes based on the provided schema and input attributes.

Kind: static method of utils
Returns: An object containing the processed attributes.

The function processes the following:

  • Splits deed and plat book/page information if specified in the schema.
  • Formats the last sale timestamp if specified in the schema.
  • Constructs owner name and address strings based on the schema keys.
  • Constructs text references for property sale and plat information.

The final attributes object includes:

  • spatialReference: The provided spatial reference or an empty string.
  • LegalDescr: The legal description or "N/F" if not provided.
  • OwnerName: The owner name prefixed with "N/F" if a legal description is provided.
  • PIN: The property identification number.
  • Address: The concatenated address string.
  • DeedBook: The deed book number or "XXX" if not provided.
  • DeedPage: The deed page number or "XXX" if not provided.
  • PlatBook: The plat book number or null if not provided.
  • PlatPage: The plat page number or null if not provided.
  • platRefText: The uppercase reference text for the plat book/page.
  • lastPropertySaleText: The uppercase text for the last property sale.
  • lastPropertySaleDeedText: The uppercase text for the deed book/page.
Param Description
attributes The input attributes to be processed.
schema The schema keys that define how to process the attributes.
spatialReference The spatial reference information.
county The name of the county for reference in the output.

utils.isPointInBbox(point, bbox) ⇒ boolean

Checks if a given point lies inside a bounding box.

Kind: static method of utils
Returns: boolean - Returns true if the point is inside the bounding box, otherwise false.

Param Type Description
point Position A GeoJSON position represented as [longitude, latitude].
bbox BBOX The bounding box, represented as [xmin, ymin, xmax, ymax].

Example

const point: Position = [-79.5, 34.5];
const bbox: [number, number, number, number] = [-80, 34, -79, 35];
console.log(isPointInBbox(point, bbox)); // true

utils.splitPathAtBbox(path, bbox) ⇒ Array.<Array.<Position>>

Splits a path at the edges of a bounding box. Iterates through the path and creates segments of points that are inside the bounding box.

Kind: static method of utils
Returns: Array.<Array.<Position>> - An array of path segments, where each segment is an array of positions inside the bounding box.

Param Type Description
path Array.<Position> An array of GeoJSON positions representing the path to split.
bbox BBOX The bounding box, represented as [xmin, ymin, xmax, ymax].

Example

const path: Position[] = [[-80, 34], [-79.5, 34.5], [-79, 35]];
const bbox: [number, number, number, number] = [-80, 34, -79, 35];
const segments = splitPathAtBbox(path, bbox);
console.log(segments);
// Output: [
//   [[-80, 34], [-79.5, 34.5], [-79, 35]]
// ]

geometryFilter : object

Utility functions for filtering geometry coordinates based on bounding boxes.

Kind: global namespace

geometryFilter.filterCoordinates(coordinates, bbox) ⇒ Array

Filters coordinates within the specified bounding box.

Recursively filters coordinates for different GeoJSON geometries including Point, LineString, Polygon, MultiLineString, and MultiPolygon.

Kind: static method of geometryFilter
Returns: Array - The filtered coordinates within the bounding box. The structure matches the input geometry type.

Param Type Description
coordinates Array The GeoJSON coordinates to filter. Can be a nested array representing different geometry types.
bbox Array.<number> The bounding box, represented as [xmin, ymin, xmax, ymax].

Example

const coordinates = [
  [[-80, 34], [-79.5, 34.5], [-79, 35]],
  [[-81, 33], [-80, 34], [-79.5, 34.5]]
];
const bbox = [-80, 34, -79, 35];
const filtered = filterCoordinates(coordinates, bbox);
console.log(filtered);
// Output: [
//   [[-80, 34], [-79.5, 34.5]],
//   []
// ]

geometryUtils : object

Utility functions for fetching, converting, and buffering geometry data.

Kind: global namespace

geometryUtils.fromProjection : string

Projection system for converting coordinates from WKID 3361 to WGS84.

Kind: static constant of geometryUtils

geometryUtils.toProjection : string

WGS84 projection used as the target projection.

Kind: static constant of geometryUtils

geometryUtils.feetToDegrees(feet) ⇒ number

Converts a distance from feet to degrees.

Kind: static method of geometryUtils
Returns: number - The equivalent distance in degrees.

Param Type Description
feet number The distance in feet to be converted.

Example

const degrees = feetToDegrees(5280); // Convert 1 mile to degrees
console.log(degrees); // Approx. 0.014472

geometryUtils.fetchConvertAndBufferGeometry(region, pin, bufferFeet) ⇒ Promise.<Buffer>

Fetches geometry data for a given region and PIN, converts coordinates from WKID 3361 to WGS84, calculates the centroid, and generates a buffered polygon around the centroid.

Kind: static method of geometryUtils
Returns: Promise.<Buffer> - A promise resolving to a polygon array representing the buffered region.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param Type Description
region string The region identifier for the API request.
pin string The PIN identifier for the API request.
bufferFeet number The buffer distance in feet.

Example

const region = "horry";
const pin = "12345";
const bufferFeet = 100;
const bufferedPolygon = await fetchConvertAndBufferGeometry(region, pin, bufferFeet);
console.log(bufferedPolygon);
// Output: [
//   [-79.2, 34.0],
//   [-79.2, 34.1],
//   [-79.1, 34.1],
//   [-79.1, 34.0],
//   [-79.2, 34.0]
// ]

geometryUtils.calculateCentroid(polyline) ⇒ Point2d | null

Calculates the centroid of a closed polyline.

Kind: static method of geometryUtils
Returns: Point2d | null - The centroid as a Point2d, or null if the polyline is invalid.
Throws:

  • Error Throws an error if the polyline has fewer than 3 vertices.
Param Type Description
polyline Polyline An array of points representing the polyline.

Example

const polyline = [
  { x: 0, y: 0 },
  { x: 4, y: 0 },
  { x: 4, y: 3 },
  { x: 0, y: 3 },
  { x: 0, y: 0 }
];
const centroid = calculateCentroid(polyline);
console.log(centroid); // { x: 2, y: 1.5 }

geometryUtils.convertRingsToPolyline(rings) ⇒ Polyline

Converts a rings array to a Polyline format.

Kind: static method of geometryUtils
Returns: Polyline - A Polyline array with points in {x, y} format.
Throws:

  • Error Throws an error if the input is invalid.
Param Type Description
rings Array.<Array.<Array.<number>>> An array representing rings of points in the form [[[x, y], [x, y], ...]].

Example

const rings = [
  [
    [0, 0],
    [4, 0],
    [4, 3],
    [0, 3],
    [0, 0]
  ]
];
const polyline = convertRingsToPolyline(rings);
console.log(polyline);
// Output: [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 3 }, { x: 0, y: 3 }, { x: 0, y: 0 }]

geometryUtils : object

Utilities for geometric calculations, including centroid calculation and polyline conversion.

Kind: global namespace

geometryUtils.fromProjection : string

Projection system for converting coordinates from WKID 3361 to WGS84.

Kind: static constant of geometryUtils

geometryUtils.toProjection : string

WGS84 projection used as the target projection.

Kind: static constant of geometryUtils

geometryUtils.feetToDegrees(feet) ⇒ number

Converts a distance from feet to degrees.

Kind: static method of geometryUtils
Returns: number - The equivalent distance in degrees.

Param Type Description
feet number The distance in feet to be converted.

Example

const degrees = feetToDegrees(5280); // Convert 1 mile to degrees
console.log(degrees); // Approx. 0.014472

geometryUtils.fetchConvertAndBufferGeometry(region, pin, bufferFeet) ⇒ Promise.<Buffer>

Fetches geometry data for a given region and PIN, converts coordinates from WKID 3361 to WGS84, calculates the centroid, and generates a buffered polygon around the centroid.

Kind: static method of geometryUtils
Returns: Promise.<Buffer> - A promise resolving to a polygon array representing the buffered region.
Throws:

  • Error Throws an error if data fetching or processing fails.
Param Type Description
region string The region identifier for the API request.
pin string The PIN identifier for the API request.
bufferFeet number The buffer distance in feet.

Example

const region = "horry";
const pin = "12345";
const bufferFeet = 100;
const bufferedPolygon = await fetchConvertAndBufferGeometry(region, pin, bufferFeet);
console.log(bufferedPolygon);
// Output: [
//   [-79.2, 34.0],
//   [-79.2, 34.1],
//   [-79.1, 34.1],
//   [-79.1, 34.0],
//   [-79.2, 34.0]
// ]

geometryUtils.calculateCentroid(polyline) ⇒ Point2d | null

Calculates the centroid of a closed polyline.

Kind: static method of geometryUtils
Returns: Point2d | null - The centroid as a Point2d, or null if the polyline is invalid.
Throws:

  • Error Throws an error if the polyline has fewer than 3 vertices.
Param Type Description
polyline Polyline An array of points representing the polyline.

Example

const polyline = [
  { x: 0, y: 0 },
  { x: 4, y: 0 },
  { x: 4, y: 3 },
  { x: 0, y: 3 },
  { x: 0, y: 0 }
];
const centroid = calculateCentroid(polyline);
console.log(centroid); // { x: 2, y: 1.5 }

geometryUtils.convertRingsToPolyline(rings) ⇒ Polyline

Converts a rings array to a Polyline format.

Kind: static method of geometryUtils
Returns: Polyline - A Polyline array with points in {x, y} format.
Throws:

  • Error Throws an error if the input is invalid.
Param Type Description
rings Array.<Array.<Array.<number>>> An array representing rings of points in the form [[[x, y], [x, y], ...]].

Example

const rings = [
  [
    [0, 0],
    [4, 0],
    [4, 3],
    [0, 3],
    [0, 0]
  ]
];
const polyline = convertRingsToPolyline(rings);
console.log(polyline);
// Output: [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 3 }, { x: 0, y: 3 }, { x: 0, y: 0 }]

utils : object

Utility functions for geometric operations, including bounding box checks and path splitting.

Kind: global namespace

utils.agent : https.Agent

HTTPS Agent for making requests with legacy SSL support.

Kind: static constant of utils

utils.formatBookPage(input) ⇒ Object

Parses a string to extract the book and page components. The input format should be either part1-part2 or part1 part2.

Kind: static method of utils
Returns: Object - An object containing the parsed book and page values.

Param Type Description
input string The string input containing book and page information.

Example

const { book, page } = formatBookPage("123-456");
console.log(book, page); // "123", "456"

utils.formatTimestampToDate(timestamp) ⇒ string

Converts a timestamp into a human-readable date string in the format MM/DD/YYYY.

Kind: static method of utils
Returns: string - The formatted date string.

Param Type Description
timestamp number The Unix timestamp in milliseconds.

Example

const date = formatTimestampToDate(1672531200000);
console.log(date); // "01/01/2023"

utils.generateAttributes(attributes, schema, spatialReference, county) ⇒

Generates a set of attributes based on the provided schema and input attributes.

Kind: static method of utils
Returns: An object containing the processed attributes.

The function processes the following:

  • Splits deed and plat book/page information if specified in the schema.
  • Formats the last sale timestamp if specified in the schema.
  • Constructs owner name and address strings based on the schema keys.
  • Constructs text references for property sale and plat information.

The final attributes object includes:

  • spatialReference: The provided spatial reference or an empty string.
  • LegalDescr: The legal description or "N/F" if not provided.
  • OwnerName: The owner name prefixed with "N/F" if a legal description is provided.
  • PIN: The property identification number.
  • Address: The concatenated address string.
  • DeedBook: The deed book number or "XXX" if not provided.
  • DeedPage: The deed page number or "XXX" if not provided.
  • PlatBook: The plat book number or null if not provided.
  • PlatPage: The plat page number or null if not provided.
  • platRefText: The uppercase reference text for the plat book/page.
  • lastPropertySaleText: The uppercase text for the last property sale.
  • lastPropertySaleDeedText: The uppercase text for the deed book/page.
Param Description
attributes The input attributes to be processed.
schema The schema keys that define how to process the attributes.
spatialReference The spatial reference information.
county The name of the county for reference in the output.

utils.isPointInBbox(point, bbox) ⇒ boolean

Checks if a given point lies inside a bounding box.

Kind: static method of utils
Returns: boolean - Returns true if the point is inside the bounding box, otherwise false.

Param Type Description
point Position A GeoJSON position represented as [longitude, latitude].
bbox BBOX The bounding box, represented as [xmin, ymin, xmax, ymax].

Example

const point: Position = [-79.5, 34.5];
const bbox: [number, number, number, number] = [-80, 34, -79, 35];
console.log(isPointInBbox(point, bbox)); // true

utils.splitPathAtBbox(path, bbox) ⇒ Array.<Array.<Position>>

Splits a path at the edges of a bounding box. Iterates through the path and creates segments of points that are inside the bounding box.

Kind: static method of utils
Returns: Array.<Array.<Position>> - An array of path segments, where each segment is an array of positions inside the bounding box.

Param Type Description
path Array.<Position> An array of GeoJSON positions representing the path to split.
bbox BBOX The bounding box, represented as [xmin, ymin, xmax, ymax].

Example

const path: Position[] = [[-80, 34], [-79.5, 34.5], [-79, 35]];
const bbox: [number, number, number, number] = [-80, 34, -79, 35];
const segments = splitPathAtBbox(path, bbox);
console.log(segments);
// Output: [
//   [[-80, 34], [-79.5, 34.5], [-79, 35]]
// ]

endpointsFiles : Array.<string>

List of endpoint files to generate Swagger documentation for.

Kind: global constant

doc : SwaggerDoc

Swagger documentation configuration object.

Kind: global constant

app : express.Application

Kind: global constant

app.cleanup() ⇒ Promise.<void>

Handles cleanup operations on process termination. Closes the MongoDB connection and exits the process.

Kind: static method of app

PORT : number | string

The port on which the server will run.

Kind: global constant

adminRouter : Router

Router for admin-related database operations.

Kind: global constant

client : MongoClient

MongoDB client instance used to connect to the database.

Kind: global constant

agent : https.Agent

HTTPS agent for handling requests with legacy SSL support.

Kind: global constant

router : express.Router

Express router for handling county-based parcel data requests.

Kind: global constant

router.GET /:state/:county/pin(req, res) ⇒ Promise.<void>

Fetches parcel data for a given state, county, and PIN (Parcel Identification Number).

If no PIN is provided, an example PIN from the county schema is used. Fetches the parcel data using the county schema's base URL and spatial reference.

Kind: static method of router
Returns: Promise.<void> - JSON response containing parcel data or an error message.

Param Type Description
req Request The Express request object.
req.params.state string The state code (e.g., "SC").
req.params.county string The county name (e.g., "Horry").
[req.query.pin] string The optional Parcel Identification Number (PIN) for fetching data.
res Response The Express response object.

Example

// Example request:
// GET /SC/Horry/pin?pin=123456

// Example response:
// {
//   features: [
//     {
//       type: 'parcel',
//       layer: 'VB-PROP-BNDY-LINE-E',
//       attributes: { ... },
//       centroid: { x: 12345, y: 67890 },
//       geometry: { rings: [ ... ] }
//     }
//   ]
// }

router : *

Description placeholder

Kind: global constant

router.GET /:state/:county/pin(req, res) ⇒ Promise.<void>

Fetches parcel data for a given state, county, and PIN (Parcel Identification Number).

If no PIN is provided, an example PIN from the county schema is used. Fetches the parcel data using the county schema's base URL and spatial reference.

Kind: static method of router
Returns: Promise.<void> - JSON response containing parcel data or an error message.

Param Type Description
req Request The Express request object.
req.params.state string The state code (e.g., "SC").
req.params.county string The county name (e.g., "Horry").
[req.query.pin] string The optional Parcel Identification Number (PIN) for fetching data.
res Response The Express response object.

Example

// Example request:
// GET /SC/Horry/pin?pin=123456

// Example response:
// {
//   features: [
//     {
//       type: 'parcel',
//       layer: 'VB-PROP-BNDY-LINE-E',
//       attributes: { ... },
//       centroid: { x: 12345, y: 67890 },
//       geometry: { rings: [ ... ] }
//     }
//   ]
// }

WKID_3361 : string

${1:Description placeholder}

Kind: global constant

FIPS_3900 : string

${1:Description placeholder}

Kind: global constant

agent : https.Agent

HTTPS agent for handling requests with legacy SSL support.

Kind: global constant

fetchCountySchema(dbName, county) ⇒

Fetches the schema for a specific county from a MongoDB database.

Kind: global function
Returns: A promise that resolves to a CountySchema object containing the schema details. If the schema is not found or an error occurs, a default CountySchema object is returned.
Throws:

  • Will log an error message if there is an issue retrieving data from the database.
Param Description
dbName The name of the database to connect to.
county The name of the county collection to fetch the schema from.

generateMarkdown(swaggerData) ⇒ string

Converts Swagger documentation JSON into a Markdown string for use in a README file.

Kind: global function
Returns: string - The generated Markdown string.

Param Type Description
swaggerData Object The Swagger documentation JSON object.

Example

const markdown = generateMarkdown(swaggerData);
console.log(markdown);

authenticateToken(req, res, next)

Description placeholder

Kind: global function

Param Type
req AuthenticatedRequest
res express.Response
next express.NextFunction

fetchGisFolders(baseUrl) ⇒ Promise.<Array.<string>>

Fetches GIS folders from a given base URL.

Kind: global function
Returns: Promise.<Array.<string>> - An array of service URLs within the folders.
Throws:

  • Will throw an error if the data cannot be fetched or processed.
Param Type Description
baseUrl string The base URL for the GIS service.

fetchGisServices(baseUrl) ⇒ Promise.<Array.<string>>

Fetches GIS services directly from a given base URL.

Kind: global function
Returns: Promise.<Array.<string>> - An array of service URLs within the services.
Throws:

  • Will throw an error if the data cannot be fetched or processed.
Param Type Description
baseUrl string The base URL for the GIS service.

fetchAllGis(baseUrl) ⇒ Promise.<Array.<string>>

Fetches both GIS folders and services and combines their URLs.

Kind: global function
Returns: Promise.<Array.<string>> - An array of combined folder and service URLs.
Throws:

  • Will throw an error if either folders or services cannot be fetched.
Param Type Description
baseUrl string The base URL for the GIS service.

dataFetch(baseUrl) ⇒ Promise.<Array.<any>>

Fetches all data layers from a GIS base URL.

Kind: global function
Returns: Promise.<Array.<any>> - An array of layer data.
Throws:

  • Will throw an error if data cannot be fetched or processed.
Param Type Description
baseUrl string The base URL for the GIS service.

isPointInsidePolygon(point, polygon) ⇒

Determines if a given point is inside a polygon.

This function uses the ray-casting algorithm to determine if the point is inside the polygon. It works by drawing a horizontal line from the point to the outside of the polygon and counting how many times the line intersects with the edges of the polygon. If the number of intersections is odd, the point is inside the polygon. If even, the point is outside.

Kind: global function
Returns: true if the point is inside the polygon, false otherwise.

Param Description
point The point to check, represented as a tuple [x, y].
polygon The polygon to check against, represented as an array of paths, where each path is an array of points [x, y]. The first path in the array is considered the outer boundary of the polygon.

doSegmentsIntersect(p1, p2, q1, q2) ⇒

Determines if two line segments intersect and returns the intersection point if they do.

Kind: global function
Returns: The intersection point as a tuple [x, y] if the segments intersect within their bounds, otherwise null.

Param Description
p1 The starting position of the first line segment as a tuple [x, y].
p2 The ending position of the first line segment as a tuple [x, y].
q1 The starting position of the second line segment as a tuple [x, y].
q2 The ending position of the second line segment as a tuple [x, y].

splitPathAtIntersection(polygon1, polygon2) ⇒

Splits the path of the first polygon at intersections with the second polygon and merges the resulting paths.

Kind: global function
Returns: An array containing the merged paths after splitting at intersections.

The function works as follows:

  1. Initializes an empty array splitPaths to store the resulting paths.
  2. Extracts the first path from each polygon (path1 and path2).
  3. Iterates through each segment of the first polygon (path1).
  4. For each segment, checks if the start point is inside the second polygon (polygon2).
  5. Checks for intersections between the current segment of the first polygon and all edges of the second polygon.
  6. If an intersection is found, starts a new path from the intersection point.
  7. Adds the end point of the current segment to the current path if it is inside the second polygon.
  8. Ensures no duplicate points are added by checking the last point in the current path.
  9. Merges the resulting paths and returns the merged path.
Param Description
polygon1 The first polygon represented as an array of arrays of positions (coordinates).
polygon2 The second polygon represented as an array of arrays of positions (coordinates).

offsetPolygon(polygonCoords, offsetDistance, spatialReference) ⇒

Offsets a polygon by a given distance and reprojects the coordinates.

Kind: global function
Returns: The new polygon with offset coordinates in the original projection.
Throws:

  • Will throw an error if the offset polygon is undefined.
Param Description
polygonCoords The coordinates of the polygon to be offset. It is a 3D array of numbers.
offsetDistance The distance by which to offset the polygon.
spatialReference The spatial reference system identifier (e.g., EPSG code) for the input coordinates.

SwaggerInfo : Object

Kind: global typedef
Properties

Name Type Description
title string The title of the API.
description string The description of the API.
version string The version of the API.

SwaggerServer : Object

Kind: global typedef
Properties

Name Type Description
url string The server URL.

SwaggerDoc : Object

Kind: global typedef
Properties

Name Type Description
info SwaggerInfo Information about the API.
host string The host URL for the API.
servers Array.<SwaggerServer> An array of server objects.