Expand description
§S2 JSON 🌎 🗺️
________
/ ___/__ \
\__ \__/ /
___/ / __/
/____/____/
_______ ____ _ __
/ / ___// __ \/ | / /
__ / /\__ \/ / / / |/ /
/ /_/ /___/ / /_/ / /| /
\____//____/\____/_/ |_/ §Install
cargo add s2json§About
A collection of geospatial base types primarily designed for WGS84, Web Mercator, and S2.
This library is designed to be lightweight with minimal dependencies. All code is no_std
complient, denies unsafe code, and can be used in any environment.
§Usage
The Documentation is very thorough in this library. Therefore the best thing to do is follow the links provided as needed.
This library wraps both a GeoJSON spec and the newer S2 JSON spec. For tooling that builds ontop of this library, see gis-tools.
§Core
§Top Level Topology
crate::FeatureCollection: WG FeatureCollection following the GeoJSON speccrate::S2FeatureCollection: S2 FeatureCollection following the S2JSON speccrate::Feature: WG Feature following the GeoJSON speccrate::VectorFeature: S2 Feature following both the S2JSON speccrate::Attributions: A list of attributions. Used bycrate::FeatureCollectionandcrate::S2FeatureCollectioncrate::FeatureCollections: An enum of eithercrate::FeatureCollectionorcrate::S2FeatureCollectioncrate::Features: An enum of eithercrate::Featureorcrate::VectorFeaturecrate::JSONCollection: A JSON FeatureCollection can be any ofcrate::FeatureCollection,crate::S2FeatureCollection,crate::Feature, orcrate::VectorFeature
§Bounding Boxes
crate::BBox: A BBOX is defined in lon-lat space and helps with zooming motion to see the entire line or polygon The order is (left, bottom, right, top) If WM, then the projection is lon-lat If S2, then the projection is s-tcrate::BBox3D: A BBOX is defined in lon-lat space and helps with zooming motion to see the entire 3D line or polygoncrate::BBOX: BBox or BBox3D enum
§Primitive Types
Note that [crate::MValue] is the key type used by the rest of the library, gis-tools, s2tiles, s2maps, etc.
Allows a lot of cool encoding/decoding mechanics along with better rendering tools.
crate::Axis: The axis to apply an operation tocrate::Projection: Enum for the WG or S2 Projectionscrate::Face: Cube-face on the S2 sphere. Optionss are [0, 5] inclusive.crate::PrimitiveValue:crate::ValuePrimitiveType:crate::ValueType:- [
crate::ValuePrimitive] /crate::MapboxProperties: crate::Value/ [crate::Properties] / [crate::MValue]:crate::MValues:crate::JSONValue:- [
crate::JSONProperties]:
§Geoemtry
crate::STPoint: An Point in S2 Space with a Face
Primitives
crate::Point: A very basic cheap X-Y pointcrate::MultiPoint: An array ofcrate::Pointcrate::LineString: An array ofcrate::Pointcrate::MultiLineString: An array ofcrate::LineStringcrate::Polygon: An array ofcrate::LineStringcrate::MultiPolygon: An array ofcrate::Polygoncrate::Point3D: A very basic 3D X-Y-Z pointcrate::MultiPoint3D: An array ofcrate::Point3Dcrate::LineString3D: An array ofcrate::Point3Dcrate::MultiLineString3D: An array ofcrate::LineString3Dcrate::Polygon3D: An array ofcrate::LineString3Dcrate::MultiPolygon3D: An array ofcrate::Polygon3Dcrate::PointOrPoint3D: Either acrate::Pointorcrate::Point3Dcrate::GeometryType: The type of geometrycrate::Geometry: The geometry. An enum of all primtive geometry types
Vector Primitives
crate::VectorPoint: A Vector Point uses a structure for both 2D or 3D points. Useful for geometry that also has m-valuescrate::VectorMultiPoint: An array ofcrate::VectorPointcrate::VectorLineString: An array ofcrate::VectorPointcrate::VectorMultiLineString: An array ofcrate::VectorLineStringcrate::VectorPolygon: An array ofcrate::VectorLineStringcrate::VectorMultiPolygon: An array ofcrate::VectorPolygoncrate::VectorGeometryType: The type of vector geometrycrate::VectorGeometry: The vector geometry. An enum of all vector geometry typescrate::VectorOffsets: The offsets for a vector geometry (rarely used)
§Traits
These traits are the fundamental building box for all geometry tooling. If you need your own custom data structure you can implement these traits and use all the tools built not only in this library but gis-tools as well.
Getters
crate::GetXY: Get the X and Y coordinates of a pointcrate::GetZ: Get the Z coordinate of a pointcrate::GetXYZ: Get the X, Y, and Z coordinates of a pointcrate::GetM: Get the M coordinate of a pointcrate::GetXYZM: Get the X, Y, Z, and M coordinates of a point
Setters
crate::SetXY: Set the X and Y coordinates of a pointcrate::SetZ: Set the Z coordinate of a pointcrate::SetXYZ: Set the X, Y, and Z coordinates of a pointcrate::SetM: Set the M coordinate of a pointcrate::SetXYZM: Set the X, Y, Z, and M coordinates of a point
New
crate::NewXY: Get and Set the X and Y coordinates of a pointcrate::NewXYM: Get and Set the X, Y, and M coordinates of a pointcrate::NewXYZ: Get and Set the X, Y, and Z coordinates of a pointcrate::NewXYZM: Get and Set the X, Y, Z, and M coordinates of a point
Full Get, New, and Set
crate::FullXY: Get, New, and Set the X and Y coordinates of a pointcrate::FullXYM: Get, New, and Set the X, Y, and M coordinates of a pointcrate::FullXYZ: Get, New, and Set the X, Y, and Z coordinates of a pointcrate::FullXYZM: Get, New, and Set the X, Y, Z, and M coordinates of a point
Utilities
You probably won’t have to implement these. Created for convenience.
crate::MValueCompatible: Descriptor of all the traits that make using M-Value tools simplecrate::Bounded: Used byBBoxandBBox3D. Defines a min and max value.crate::Interpolate: Easy access to interpolation tooling for All S2JSON Core Types
§Derives
crate::MValueCompatible: Ensure M implements All MValue Traits used by VectorPointscrate::JSONPropertiesCompatible: Ensure M implements All MValue Traits used by complex GeoJSON properties. Not used by gis-tools.- [
crate::Properties]: Ensure M implements All MValue Traits used by VectorPoints - [
crate::MValue]: Ensure M implements All MValue Traits used by VectorPoints - [
crate::ValuePrimitive]: Sub type used by [crate::MValue] - [
crate::JSONProperties]: JSON Properties specification to-from mechanics
Modules§
- geometry
- All geometry types and structs
- impls
- All json, value, shape impl
- map
- BTreeMap wrapper
- shape
- All shape types and structs
- value
- All values types and structs
Structs§
- BBox
- Bounding Box
- BBox3D
- 3D Bounding Box
- Base
Geometry - BaseGeometry is the a generic geometry type
- Feature
- Component to build an WG Feature
- Feature
Collection - WG FeatureCollection
- Map
- A BTreeMap wrapper
- Point
- Definition of a Point. May represent WebMercator Lon-Lat or S2Geometry S-T
- Point3D
- Definition of a 3D Point. May represent WebMercator Lon-Lat or S2Geometry S-T with a z-value
- Point
OrPoint3D - Define a Point or Point3D
- S2Feature
Collection - S2 FeatureCollection
- STPoint
- A Point in S2 Space with a Face
- Vector
Base Geometry - BaseGeometry is the a generic geometry type
- Vector
Feature - Component to build an WG or S2 Vector Feature
- Vector
Point - Vector Points
Enums§
- Axis
- The axis to apply an operation to
- BBOX
- BBox or BBox3D
- Face
- Cube-face on the S2 sphere
- Feature
Collection Type - FeatureCollection type string
- Feature
Collections - Either an S2 or WG FeatureCollection
- Feature
Type - Feature type string
- Features
- Either an S2, Vector WG or WG Feature
- Geometry
- All possible geometry shapes
- Geometry
Type - Enum to represent specific geometry types as strings
- JSON
Collection - All major GeoJSON and S2JSON types
- JSON
Value - All possible JSON shapes
- MValues
- All possible M-Value shapes
- Primitive
Shape - Primitive types that can be found in a shape
- Primitive
Shape Type - Arrays may contain either a primitive or an object whose values are primitives
- Primitive
Value - Primitive types supported by Properties
- Projection
- All projections that can be used
- S2Feature
Collection Type - FeatureCollection type string
- Shape
Type - Shape types that can be found in a shapes object. Either a primitive, an array containing any type, or a nested shape. If the type is an array, all elements must be the same type
- Value
Primitive Type - Arrays may contain either a primitive or an object whose values are primitives
- Value
Type - Supports primitive types
string,number,boolean,nullMay be an array of those primitive types, or an object whose values are only primitives Object keys are always strings, values can be any basic type, an array, or a nested object. Array values must all be the same type. - Vector
Feature Type - Feature type string
- Vector
Geometry - Vector Geometry
- Vector
Geometry Type - Enum to represent specific vector geometry types as strings
- Vector
Offsets - All possible geometry offsets
Traits§
- Bounded
- Trait for types that have a min and max value. Used by
BBoxandBBox3D - FullXY
- Composite Trait for XY use cases
- FullXYM
- Composite Trait for XYM use cases
- FullXYZ
- Composite Trait for XYZ use cases
- FullXYZM
- Composite Trait for XYZM use cases
- GetM
- Trait to extract the m value
- GetXY
- Trait to extract the x and y values
- GetXYM
- Composite Trait: XY + M
- GetXYZ
- Composite Trait: XY + Z
- GetXYZM
- Composite Trait: XY + Z + M
- GetZ
- Trait to extract the z value
- Interpolate
- Easy access to interpolation tooling for All S2JSON Core Types
- JSON
Properties Compatible - Ensure M implements MValueCompatible
- MValue
Compatible - Ensure M implements MValueCompatible
- NewXY
- Trait to create a new XY
- NewXYM
- Trait to create a new XY
- NewXYZ
- Trait to create a new XYZ
- NewXYZM
- Trait to create a new XYZM
- SetM
- Trait to set the m value
- SetXY
- Trait to set the x and y values
- SetXYM
- Composite Trait: XY + M
- SetXYZ
- Composite Trait: XY + Z
- SetXYZM
- Composite Trait: XY + Z + M
- SetZ
- Trait to set the z value
Type Aliases§
- Attributions
- Attribution data is stored in an object. The key is the name of the attribution, and the value is the href link e.g. { “Open S2”: “https://opens2.com/legal/data” }
- JSON
Properties - Shape of an un-restricted features properties object
- Line
String - Definition of a LineString
- Line
String3D - Definition of a 3D LineString
- Line
String3D Geometry - LineString3DGeometry is a 3D line
- Line
String Geometry - LineStringGeometry is a line
- Line
StringM Values - LineString Properties Shape
- MValue
- Shape of a feature’s M-Values object
- Mapbox
Properties - Shape of the restricted Mapbox properties object
- Multi
Line String - Definition of a MultiLineString
- Multi
Line String3D - Definition of a 3D MultiLineString
- Multi
Line String3D Geometry - MultiLineString3DGeometry contains multiple 3D lines
- Multi
Line String Geometry - MultiLineStringGeometry contains multiple lines
- Multi
Line StringM Values - MultiLineString MValues Shape
- Multi
Point - Definition of a MultiPoint
- Multi
Point3D - Definition of a 3D MultiPoint
- Multi
Point3D Geometry - MultiPoint3DGeometry contains multiple 3D points
- Multi
Point Geometry - MultiPointGeometry contains multiple points
- Multi
Polygon - Definition of a MultiPolygon
- Multi
Polygon3D - Definition of a 3D MultiPolygon
- Multi
Polygon3D Geometry - MultiPolygon3DGeometry is a 3D polygon with multiple polygons with their own potential holes
- Multi
Polygon Geometry - MultiPolygonGeometry is a polygon with multiple polygons with their own potential holes
- Multi
PolygonM Values - MultiPolygon MValues Shape
- Point3D
Geometry - Point3DGeometry is a 3D point
- Point
Geometry - PointGeometry is a point
- Polygon
- Definition of a Polygon
- Polygon3D
- Definition of a 3D Polygon
- Polygon3D
Geometry - Polygon3DGeometry is a 3D polygon with potential holes
- Polygon
Geometry - PolygonGeometry is a polygon with potential holes
- PolygonM
Values - Polygon MValues Shape
- Properties
- Shape of a features properties object
- Shape
- The Shape Object
- Shape
Primitive - The Primitive Shape Object
- Value
- Shape design
- Value
Primitive - Shape of a ValuePrimitiveType Nested object
- Vector
Line Offset - An offset defines how far the starting line is from the original starting point pre-slice
- Vector
Line String - Definition of a Vector LineString
- Vector
Line String Geometry - LineStringGeometry is a line
- Vector
Multi Line Offset - A collection of offsets
- Vector
Multi Line String - Definition of a Vector MultiLineString
- Vector
Multi Line String Geometry - MultiLineStringGeometry contains multiple lines
- Vector
Multi Point - Definition of a Vector MultiPoint
- Vector
Multi Point Geometry - MultiPointGeometry contains multiple points
- Vector
Multi Polygon - Definition of a Vector MultiPolygon
- Vector
Multi Polygon Geometry - MultiPolygonGeometry is a polygon with multiple polygons with their own potential holes
- Vector
Multi Polygon Offset - A collection of collections of offsets
- Vector
Point Geometry - PointGeometry is a point
- Vector
Polygon - Definition of a Vector Polygon
- Vector
Polygon Geometry - PolygonGeometry is a polygon with potential holes
- Vector
Polygon Offset - A collection of offsets
Derive Macros§
- JSON
Properties derive - Derives the
JSONPropertiestrait for a struct to convert it to aJSONProperties. - MValue
derive - Derives the
MValuetrait for a struct to convert it to aMValue. - MValue
Compatible derive - Derives the
MValueCompatibletrait for a struct to convert it to aMValue. - Properties
derive - Derives the
Propertiestrait for a struct to convert it to aProperties. - Value
Primitive derive - Derives the
ValuePrimitivetrait for a struct to convert it to aValuePrimitive.