Geospatiale

Geospatiale

The namespace for all UF/Geospatiale utility functions, typically for static methods.

Regular operations use Turf.performant, which is a custom fork of Turf.js. It has the same syntax, but features 60-120x the performance (average over union, difference, intersect).

See GeoJSON converters (i.e. convertMaptalksToTurf, convertTurfToMaptalks) for information on its usage. For frontend GIS editing, please review Naissance HGIS.

Source:

Classes

maptalks_CurvedLabel
maptalks_GeoKMZ

Methods

(static) cleanRings(arg0_geojson_feature) → {Object|null}

Cleans rings within a GeoJSON FeatureCollection/MultiPolygon/Polygon to ensure Turf.js validity.

Source:
Parameters:
Name Type Description
arg0_geojson_feature Object
Returns:
Type:
Object | null

(static) computeTPSCoefficients(arg0_mesh_points) → {Object}

Computes the Thin Plate Spline (TPS) coefficients for a given set of mesh points.

Source:
Parameters:
Name Type Description
arg0_mesh_points Array.<Object>

An array of points containing x, y (target) and src_x, src_y (source).

Returns:
Type:
Object

An object containing the solved coefficients for the x and y dimensions.

(static) convertEventToWorld(arg0_e, arg1_canvas_rect, arg2_factor, arg3_buffer_offset) → {Object}

Converts a browser mouse event into world/canvas coordinate space.

Source:
Parameters:
Name Type Description
arg0_e MouseEvent

The mouse event object.

arg1_canvas_rect DOMRect

The bounding client rectangle of the canvas.

arg2_factor number

The current scale/zoom factor.

arg3_buffer_offset number

The offset buffer applied to the coordinates.

Returns:
Type:
Object

An object containing the x and y coordinates in world space.

(static) convertLeafletSymbolToMaptalks(arg0_symbol) → {Object}

Converts a Leaflet symbol to Maptalks.

Source:
Parameters:
Name Type Description
arg0_symbol Object
Returns:
Type:
Object

(static) convertMaptalksToTurf(arg0_geometry) → {Object|turf.Feature|null}

Converts a maptalks.Geometry into a turf.Geometry.

Source:
Parameters:
Name Type Description
arg0_geometry maptalks.Geometry
Returns:
Type:
Object | turf.Feature | null

(static) convertTurfToMaptalks(arg0_geometry) → {maptalks.Geometry|maptalks.GeometryCollection}

Converts a turf.Geometry into a maptalks.Geometry

Source:
Parameters:
Name Type Description
arg0_geometry turf.Geometry
Returns:
Type:
maptalks.Geometry | maptalks.GeometryCollection

(static) delaunayTriangulate(arg0_points, arg1_image_centre) → {Array.<number>}

Performs Delaunay triangulation on a set of 2D points.

Source:
Parameters:
Name Type Description
arg0_points Array.<Object>

Array of objects with x and y properties.

arg1_image_centre number

The coordinate to be treated as the centre for the super-triangle calculation.

Returns:
Type:
Array.<number>

A flat array of indices representing triangles.

(static) drawMeshOverlay(arg0_ctx, arg1_mesh_points, arg2_mesh_triangles, arg3_factor, arg4_base_point_radius, arg5_selected_point_index)

Draws the mesh wireframe and control points onto a canvas context.

Source:
Parameters:
Name Type Description
arg0_ctx CanvasRenderingContext2D

The target canvas context.

arg1_mesh_points Array.<Object>

Array of points representing the vertices.

arg2_mesh_triangles Array.<number>

Flat array of vertex indices for triangles.

arg3_factor number

Scale factor for line width and radius.

arg4_base_point_radius number

The base radius for rendering control points.

arg5_selected_point_index number | null

The index of the currently selected point, if any.

(static) drawTriangle(arg0_ctx, arg1_image, arg2_image_display_size, arg3_src_point, arg4_src_point, arg5_src_point, arg6_dest_point, arg7_dest_point, arg8_dest_point)

Draws a textured triangle onto the canvas by mapping source points to destination points using an affine transform.

Source:
Parameters:
Name Type Description
arg0_ctx CanvasRenderingContext2D

The target canvas context.

arg1_image HTMLImageElement

The source image to sample from.

arg2_image_display_size number

The display size of the image coordinates.

arg3_src_point Object

First source point {x, y}.

arg4_src_point Object

Second source point {x, y}.

arg5_src_point Object

Third source point {x, y}.

arg6_dest_point Object

First destination point {x, y}.

arg7_dest_point Object

Second destination point {x, y}.

arg8_dest_point Object

Third destination point {x, y}.

(static) getBarycentric(arg0_point, arg1_point, arg2_point, arg3_point) → {Object}

Calculates the barycentric coordinates of a point relative to a triangle.

Source:
Parameters:
Name Type Description
arg0_point Object

The point to test {x, y}.

arg1_point Object

First triangle vertex.

arg2_point Object

Second triangle vertex.

arg3_point Object

Third triangle vertex.

Returns:
Type:
Object

An object containing weights u, v, w and a boolean 'inside'.

(static) getCircumcircle(arg0_point, arg1_point, arg2_point) → {Object}

Calculates the circumcircle of a triangle defined by three points.

Source:
Parameters:
Name Type Description
arg0_point Object

First point.

arg1_point Object

Second point.

arg2_point Object

Third point.

Returns:
Type:
Object

An object containing the centre coordinates x, y and the radius r.

(static) getCoordsType(arg0_format) → {String}

Returns the coords/geometry format the variable represents.

Source:
Parameters:
Name Type Description
arg0_format *

The coords/geometry format to input.

Returns:
Type:
String
  • Either 'geojson_coords'/'geojson_geometry'/'leaflet_coords'/'leaflet_geometry'/'maptalks_coords'/'maptalks_geometry'/'naissance_coords'/'naissance_geometry'/'turf_coords'/'turf_geometry'.

(static) getEquirectangularCoordsPixel(arg0_lng, arg1_lat, arg2_optionsopt) → {Array.<number, number>|Object}

Fetches the x, y coordinate pair for a given pixel given latitude and longitude coordinates for WGS84 Equirectangular.

Source:
Parameters:
Name Type Attributes Description
arg0_lng number
arg1_lat number
arg2_options Object <optional>
Name Type Attributes Default Description
height number <optional>
2160

The height of the image in pixels.

width number <optional>
4320

The width of the image in pixels.

return_object boolean <optional>
false

Whether to return a structured object instead.

Returns:
Type:
Array.<number, number> | Object

(static) getEquirectangularNearestPixelWith(arg0_lng, arg1_lat, arg2_optionsopt)

Checks the nearest equirectangular pixel from a raster image that fulfills a boolean condition.

Source:
Parameters:
Name Type Attributes Description
arg0_lng number
arg1_lat number
arg2_options Object <optional>
Name Type Attributes Description
input_raster Object <optional>
special_function function <optional>

Object}, arg1_x:number, arg2_y:number) | boolean - Returns true if condition is met.

(static) getEquirectangularPixelCoords(arg0_x, arg1_y, arg2_widthopt, arg3_heightopt) → {Array.<number>}

Returns a [lat, lng] array for a given pixel coordinate.

Source:
Parameters:
Name Type Attributes Default Description
arg0_x number
arg1_y number
arg2_width number <optional>
4320
arg3_height number <optional>
2160
Returns:
Type:
Array.<number>

(static) getGoogleMapsCityCoords(arg0_city_name, arg1_optionsopt) → {Array.<number>}

Geolocates a city on Google Maps if possible.

Source:
Parameters:
Name Type Attributes Description
arg0_city_name string
arg1_options Object <optional>
Name Type Attributes Description
google_maps_api_key string <optional>
Returns:
Type:
Array.<number>

(static) getLeafletGeometryType(arg0_geometry) → {string}

Returns a Leaflet geometry type. Either 'polygon'/'line'/'point'.

Source:
Parameters:
Name Type Description
arg0_geometry Object
Returns:
Type:
string

(static) getMaptalksConstantStops(arg0_base_sizeopt, arg1_base_zoomopt) → {Array.<Array.<number>>}

Returns stops fixed to map-space (i.e. for rendering borders) rather than to screen-space. Used inside of { stops: number[][] } symbols for certain Maptalks geometries.

Source:
Parameters:
Name Type Attributes Default Description
arg0_base_size number <optional>
1
arg1_base_zoom number <optional>
0
Returns:
Type:
Array.<Array.<number>>

(static) getNominatimSearch(arg0_search_query) → {Promise.<Array.<Object>>|undefined}

Performs a Nominatim search and returns the results in JSON form.

Source:
Parameters:
Name Type Description
arg0_search_query string
Returns:
Type:
Promise.<Array.<Object>> | undefined

(static) getOSMCityCoords(arg0_city_name) → {Array.<number>}

Geolocates a city using OSM if possible.

Source:
Parameters:
Name Type Description
arg0_city_name string
Returns:
Type:
Array.<number>

(static) getPointIndexAt(arg0_x, arg1_y, arg2_mesh_points, arg3_factor, arg4_hitbox_radius) → {number|null}

Identifies the index of a mesh point within a specific hitbox radius.

Source:
Parameters:
Name Type Description
arg0_x number

X coordinate to check.

arg1_y number

Y coordinate to check.

arg2_mesh_points Array.<Object>

Array of mesh points.

arg3_factor number

Scale factor to adjust the hitbox.

arg4_hitbox_radius number

The base radius for the selection hitbox.

Returns:
Type:
number | null

The index of the point if found, otherwise null.

(static) getPoleOfInaccessibility(arg0_feature, arg1_precisionopt) → {Array.<number>|null}

Finds the pole of inaccessibility for a GeoJSON feature. Depends on npm polylabel.

Source:
Parameters:
Name Type Attributes Default Description
arg0_feature Object
arg1_precision number <optional>
0.0001
Returns:
Type:
Array.<number> | null
  • [lat, lng]

(static) getTPSPosition(arg0_src_x, arg1_src_y, arg2_mesh_points, arg3_coeffs_x, arg4_coeffs_y) → {Object}

Calculates the warped position of a source point using TPS coefficients.

Source:
Parameters:
Name Type Description
arg0_src_x number

The source x coordinate.

arg1_src_y number

The source y coordinate.

arg2_mesh_points Array.<Object>

The original mesh points.

arg3_coeffs_x Array.<number>

Solved TPS coefficients for the X dimension.

arg4_coeffs_y Array.<number>

Solved TPS coefficients for the Y dimension.

Returns:
Type:
Object

The transformed coordinates {x, y}.

(static) getTransformMatrix(arg0_src_point, arg1_src_point, arg2_src_point, arg3_dest_point, arg4_dest_point, arg5_dest_point) → {Object|null}

Computes the 2D affine transform matrix to map one triangle to another.

Source:
Parameters:
Name Type Description
arg0_src_point Object

First source point.

arg1_src_point Object

Second source point.

arg2_src_point Object

Third source point.

arg3_dest_point Object

First destination point.

arg4_dest_point Object

Second destination point.

arg5_dest_point Object

Third destination point.

Returns:
Type:
Object | null

The matrix components {a, b, c, d, e, f} or null if the triangle is degenerate.

(static) hashGeometry(arg0_geometry, arg1_optionsopt) → {string}

Hashes a geometry to detect duplicates and ensure uniqueness.

Source:
Parameters:
Name Type Attributes Description
arg0_geometry Geometry
arg1_options Object <optional>
Name Type Attributes Default Description
precision number <optional>
6

The precision to use when checking the hash.

Returns:
Type:
string

(static) haversineDistance(arg0_coords, arg1_coords) → {number}

Calculates the haversine distance in km between two [lng, lat] coords.

Source:
Parameters:
Name Type Description
arg0_coords Array.<number>
arg1_coords Array.<number>
Returns:
Type:
number

(static) isGeoJSONCoords(arg0_coords) → {boolean}

Whether the coords type being tested are loosely GeoJSON compatible.

Source:
Parameters:
Name Type Description
arg0_coords *
Returns:
Type:
boolean

(static) parseCoords(arg0_coords) → {Array.<Array.<number>>}

Parses a coords string into [lng, lat] coords.

Source:
Parameters:
Name Type Description
arg0_coords string
Returns:
Type:
Array.<Array.<number>>

(static) renderTPSGrid(arg0_ctx, arg1_image, arg2_image_display_size, arg3_grid_resolution, arg4_mesh_points, arg5_coeffs_x, arg6_coeffs_y)

Renders an image using a Thin Plate Spline grid warp.

Source:
Parameters:
Name Type Description
arg0_ctx CanvasRenderingContext2D

The target canvas context.

arg1_image HTMLImageElement

The image to warp.

arg2_image_display_size number

The logical size of the source image.

arg3_grid_resolution number

The number of grid segments per axis.

arg4_mesh_points Array.<Object>

The control points for the warp.

arg5_coeffs_x Array.<number>

TPS coefficients for the X dimension.

arg6_coeffs_y Array.<number>

TPS coefficients for the Y dimension.

(static) solveGaussianElimination(arg0_matrix, arg1_target) → {Array.<number>}

Solves a linear system of equations using Gaussian elimination with partial pivoting.

Source:
Parameters:
Name Type Description
arg0_matrix Array.<Array.<number>>

The coefficient matrix.

arg1_target Array.<number>

The right-hand side vector.

Returns:
Type:
Array.<number>

The solution vector x.

(static) sortGeometries(arg0_geometries)

Sorts Maptalks geometries in order from bottom-top (Polygon, LineString, Point)

Source:
Parameters:
Name Type Description
arg0_geometries Array.<maptalks.Geometry>

(static) splitFeature(arg0_feature, arg1_divisor_layer) → {Array.<Feature>}

Splits a feature into multiple sections based on a divisor layer.

Source:
Parameters:
Name Type Description
arg0_feature Feature
arg1_divisor_layer FeatureCollection
Returns:
Type:
Array.<Feature>

(static) translatePoint(arg0_coords, arg1_x, arg2_y) → {Object}

Translates a point by X, Y in metres.

Source:
Parameters:
Name Type Description
arg0_coords maptalks.Coordinate | Array.<number>
arg1_x number
arg2_y number
Returns:
Type:
Object