Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Microsoft.Geospatial

Brian Kircher edited this page Mar 3, 2020 · 13 revisions

AltitudeReference

The altitude reference system to be used in defining a geographic shape.

public enum Microsoft.Geospatial.AltitudeReference
    : Enum, IComparable, IFormattable, IConvertible

Enum

Value Name Summary
0 Ellipsoid The altitude reference is based on an ellipsoid which is a mathematical approximation of the shape of the Earth.
1 Terrain The altitude reference is based on distance above terrain or ground level.
2 Surface The altitude reference is based on the distance above the tallest surface structures, such as buildings, trees, roads, etc., above terrain or ground level.

Constants

Common values used by various Geospatial classes.

public static class Microsoft.Geospatial.Constants

Static Fields

Type Name Summary
Double DegreesPerRadian The number of degrees in a radian (180 / PI). This is not an exact value. This value can be used for conversion from radians to degrees. For example: degreeAngle = radianAngle * DegreesPerRadian
Double MaximumMercatorLatitudeInRadians Maximum Latitude. Anything above this will be pinned.
Double MinimumMercatorLatitudeInRadians Minimum Latitude. Anything below this will be pinned.
Double RadiansPerDegree The number of radians in a degree (PI / 180). This is not an exact value. This value can be used for conversion from degrees to radians. For example: radianAngle = degreeAngle * RadiansPerDegree

GeoBoundingBox

Defines a rectangular area in Latitude and Longitude coordinates.

public struct Microsoft.Geospatial.GeoBoundingBox
    : IEquatable<GeoBoundingBox>

Properties

Type Name Summary
LatLon BottomLeft The minimum coordinate for the GeoBoundingBox.
LatLon Center The center of the GeoBoundingBox.
IEnumerable<LatLon> Corners Enumerates each of the corners in this box.
LatLon TopRight The maximum coordinate for the GeoBoundingBox.

Methods

Type Name Summary
Boolean Equals(Object obj)
Boolean Equals(GeoBoundingBox other)
Int32 GetHashCode()
Boolean Intersects(LatLon location) Returns true if the specified location is in this GeoBoundingBox or intersects the edge of this GeoBoundingBox.
Boolean Intersects(GeoBoundingBox other) Returns true if the specified location is in this GeoBoundingBox or intersects the edge of this GeoBoundingBox.
Boolean Overlaps(IList<LatLon> ring) Tests whether this bounding box overlaps the provided polygon.
Boolean Overlaps(LatLon p1, LatLon p2) Tests whether this bounding box overlaps the provided polygon.
MercatorBoundingBox ToMercatorBoundingBox() Returns the MercatorBoundingBox for this BoundingBox.
String ToString()

LatLon

Represents Latitude + Longitude.

public struct Microsoft.Geospatial.LatLon
    : IEquatable<LatLon>

Properties

Type Name Summary
Boolean IsValid Returns true if the specified coordinate is valid.
Double LatitudeInDegrees The latitude in degrees.
Double LatitudeInRadians Gets the longitude value, converted to radians.
Double LongitudeInDegrees The longitude in degrees.
Double LongitudeInRadians Gets the latitude value, converted to radians.

Methods

Type Name Summary
Boolean ApproximatelyEquals(LatLon other, Double tolerance = 1E-09) Determines whether two LatLon coordinates are considered equal based on a precision threshold. https://msdn.microsoft.com/en-us/library/ya2zha7s(v=vs.110).aspx The default tolerance is set to 9 decimal places where the precision is approximately equal to 110 microns, since 10 decimal places or more indicates a computer or calculator was used. In our applications, it's likely to have come from calls to SQL MakeValid().
Boolean Equals(Object obj)
Boolean Equals(LatLon other)
Boolean Equals(LatLon& other)
Int32 GetHashCode()
Boolean IsOnTheEdgeOfTheWorld() Check if a vertex lies on the edge of the world, from -180 to 180 longitude, and from -90 to 90 latitude
Boolean Overlaps(IList<LatLon> ring) Determines if the point is inside or outside the ring. Uses the crossing count algorithm to count the number of times a horizontal ray from the point crosses the ring. It is assumed that though the ring is closed, it does not duplicate the first vertex.
void Read(BinaryReader reader) Hydrate the contents from binary storage. Expected order of data is Longitude, Latitude.
Vector2D ToMercatorPosition() Returns the Mercator position x,y where x and y are in the range [-0.5,0.5].
String ToString()
void Write(BinaryWriter writer) Commit their contents to binary storage.

Static Fields

Type Name Summary
Double MaximumLatitude The maximum valid latitude.
Double MaximumLongitude The maximum valid longitude.
LatLon MaxValue A Coordinate2D with maximum values for X and Y.
Double MinimumLatitude The minimum valid latitude.
Double MinimumLongitude The minimum valid longitude.
LatLon MinValue A Coordinate2D with minimum values for X and Y.
Int64 SizeInBytes Size of this struct.

Static Methods

Type Name Summary
Double DegreesToRadians(Double degrees) Converts degrees to radians.
LatLon FromMercatorPosition(Vector2D mercatorPosition) Initializes new instance of the Microsoft.Geospatial.LatLon struct by transforming a mercator position (where x andy are in the range -0.5 to 0.5).
LatLon FromRadians(Double latitudeInRadians, Double longitudeInRadians) Initializes a new instance of the Microsoft.Geospatial.LatLon struct from radians.
Double MercatorToWgs84Latitude(Double mercatorUnitLatitude) Converts from Mercator unit latitude value (-0.5...0.5) to WGS 84 latitudes in radians (-PI/2...PI/2).
Double RadiansToDegrees(Double radians) Converts radians to degrees.
Double Wgs84LatitudeToMercator(Double wgs84LatitudeInRadians) Converts from WGS 84 latitudes in radians (-PI/2...PI/2) to Mercator unit latitude value (-0.5...0.5).
Double WrapLongitude(Double longitude) Wraps a longitudinal value to the -180 to 180 range.

LatLonAlt

A latitude, longitude, and altitude.

public struct Microsoft.Geospatial.LatLonAlt
    : IEquatable<LatLonAlt>

Properties

Type Name Summary
Double AltitudeInMeters Meters, Z. This is always relative to WGS84 Datum.
Double LatitudeInDegrees The latitude in degrees.
LatLon LatLon Degrees, YX
Double LongitudeInDegrees The longitude in degrees.

Methods

Type Name Summary
Boolean Equals(Object obj)
Boolean Equals(LatLonAlt other)
Int32 GetHashCode()
String ToString()

MercatorBoundingBox

Defines a rectangular area in Mercator coordinates.

In Mercator coordiantes, X coordinates are longitudinal values and Y coordinates are latitudinal values.

The direction that the MercatorBoundingBox wraps longitudinally is determined by the X cordinate of the left and right points. If the BottomLeft X coordinate is greater than the TopRight X coordinate, the MercatorBoundingBox wraps across the anti-meridian.

public struct Microsoft.Geospatial.MercatorBoundingBox
    : IEquatable<MercatorBoundingBox>

Properties

Type Name Summary
Vector2D BottomLeft The bottom left coordinate for the MercatorBoundingBox
Vector2D Center The center of the MercatorBoundingBox in Mercator coordinates.
Vector2D TopRight The top right coordinate for the MercatorBoundingBox.

Methods

Type Name Summary
Boolean Equals(Object obj)
Boolean Equals(MercatorBoundingBox other)
Boolean Equals(MercatorBoundingBox& other)
Int32 GetHashCode()
Boolean Intersects(LatLon other) Returns true if this MercatorBoundingBox intersects the specified LatLon.
Boolean Intersects(Vector2D other) Returns true if this MercatorBoundingBox intersects the specified LatLon.
Boolean Intersects(MercatorBoundingBox other) Returns true if this MercatorBoundingBox intersects the specified LatLon.
GeoBoundingBox ToGeoBoundingBox() Converts this MercatorBoundingBox to a lat-lon Box.
String ToString()

TileId

Encompasses a single Tile Id At level of detail 0, there is one tile with a value of 1 (""). At level of detail 1, there are four tiles with values of 4 ("0"), 5 ("1"), 6 ("2"), 7 ("3"). At level of detail 2, there are sixteen tiles with value starting at 16 ("00").

public struct Microsoft.Geospatial.TileId
    : IEquatable<TileId>

Properties

Type Name Summary
Int64 Value Gets or sets the value of this tile.

Methods

Type Name Summary
Boolean Equals(Object obj) See System.Object.Equals(System.Object).
Boolean Equals(TileId other) See System.Object.Equals(System.Object).
TileId GetEast() Calculates the Microsoft.Geospatial.TileId to the East of this one, wrapping around the earth.
Int32 GetHashCode() See System.Object.GetHashCode.
TileId GetNorth() Calculates the Microsoft.Geospatial.TileId to the North of this one.
TileId GetParent() Calculate the id of the tile that is one level of detail up from this tile. This method will return Microsoft.Geospatial.TileId.Null if the this tile has no parents.
TileId GetSouth() Calculates the Microsoft.Geospatial.TileId to the South of this one.
TileId GetWest() Calculates the Microsoft.Geospatial.TileId to the West of this one, wrapping around the earth.
Boolean IsParentOf(TileId tileId) Returns whether or not the specified tile id is an immediate or distant child of this tile id.
Boolean IsParentOf(IEnumerable<TileId> tileIds) Returns whether or not the specified tile id is an immediate or distant child of this tile id.
void Read(BinaryReader reader)
String ToKey() Gets the tile id as a string tile key.
String ToString() See System.Object.ToString.
Boolean TryGetChildren(TileId[]& children) Calculate the four child tile ids of this tile id.
Boolean TryGetParent(TileId& parent) Try to calculate the id of the tile that is one level of detail up from this tile.
void Write(BinaryWriter writer)

Static Fields

Type Name Summary
TileId Null The null tile id.

Static Methods

Type Name Summary
TileId FromKey(String key) Initializes a new instance of the Microsoft.Geospatial.TileId struct from a string tile key.

TileLevelOfDetail

Encapsulates the value of a tile level-of-detail.

public struct Microsoft.Geospatial.TileLevelOfDetail
    : IComparable<TileLevelOfDetail>

Properties

Type Name Summary
Int16 Value Gets or sets the value of this object.

Methods

Type Name Summary
Int32 CompareTo(TileLevelOfDetail other)
Boolean Equals(Object obj) Overrides System.Object.Equals(System.Object).
Int32 GetHashCode() Overrides System.Object.GetHashCode.
void Read(BinaryReader reader) Populates this object with a value read in from the provided System.IO.BinaryReader.
String ToString()
void Write(BinaryWriter writer) Writes this level of detail to the provided System.IO.BinaryWriter.

Static Fields

Type Name Summary
TileLevelOfDetail Max Gets the maximum level of detail supported by the system.
Int16 MaxValue The largest Level of Detail that is supported by this class.
TileLevelOfDetail Min Gets the minimum level of detail supported by the system. This will be 0 as that is the minimum functional value even though -1 is used for null.
Int16 MinValue The smallest Level of Detail that is supported by this class.
TileLevelOfDetail Null Gets a level of detail instance for no level of detail.
Int16 NullValue Gets the level of detail value that is used to represent no level of detail.

Static Methods

Type Name Summary
TileLevelOfDetail FindHighestLowerThan(TileLevelOfDetail levelOfDetail, HashSet<TileLevelOfDetail> levelsOfDetailToCheck) find the highest valid Lod that is lower than the given one
Boolean TryParse(String value, TileLevelOfDetail& levelOfDetail) Parses the level of detail from the specified string.

TileOperations

Common operations related to TilePosition and TileId. For more basic operations using the underlying primitive types, see PrimitiveTileOperations.

public static class Microsoft.Geospatial.TileOperations

Static Methods

Type Name Summary
void CalculateBounds(this TileId tileId, Double& westLongitudeInDegrees, Double& eastLongitudeInDegrees, Double& southLatitudeInDegrees, Double& northLatitudeInDegrees) Calculates the bounding box for this tile id.
LatLon CalculateCenter(this TileId tileId) Calculates the center, in lat/lon space, of this tile id.
GeoBoundingBox CalculateGeoBoundingBox(this TileId tileId) Calculates the bounding box for this tile id.
LatLon CalculateLatLongAtPixel(this TileId tileId, Int32 xPixel, Int32 yPixel, Int32 pixelWidth, Int32 pixelHeight) Calculates the Latitude and Longitude at a given coordinate in pixel space. Pixel origin 0,0 is at the bottom left, proceeding up and to the right.
TileLevelOfDetail CalculateLevelOfDetail(this TileId tileId) Calculates the TileLevelOfDetail for the TileId.
IEnumerable<TileId> CalculateOverlappingTiles(IList<LatLon> ring, TileLevelOfDetail levelOfDetail) Returns a list of tiles that overlap the specified ring.
void GetChildren(this TileId tileId, TileId[] output) Fills out the specified array with the immediate children of this tile.
void GetChildrenTileIds(this TilePosition tilePosition, TileId[] output) Fills out the specified array with the immediate children as TileIds.
IEnumerable<TileId> GetCoveredTileIds(MercatorBoundingBox boundingBox, TileLevelOfDetail levelOfDetail) Returns an enumeration of TileIds that cover the specified MercatorBoundingBox at the given level of detail. The enumeration starts in the upper left tile and ends at the lower right tile.
IEnumerable<TileId> GetCoveredTileIds(GeoBoundingBox boundingBox, TileLevelOfDetail levelOfDetail) Returns an enumeration of TileIds that cover the specified MercatorBoundingBox at the given level of detail. The enumeration starts in the upper left tile and ends at the lower right tile.
IEnumerable<TilePosition> GetCoveredTilePositions(MercatorBoundingBox boundingBox, TileLevelOfDetail levelOfDetail) Returns an enumeration of TilePositions that cover the specified MercatorBoundingBox at the given level of detail. The enumeration starts in the upper left tile and ends at the lower right tile.
IEnumerable<TilePosition> GetCoveredTilePositions(GeoBoundingBox boundingBox, TileLevelOfDetail levelOfDetail) Returns an enumeration of TilePositions that cover the specified MercatorBoundingBox at the given level of detail. The enumeration starts in the upper left tile and ends at the lower right tile.
List<TileId> GetNeighbors(this TileId tileId) For a given tileId, returns a list containing the tile id and all (up to 8) neighbors for that tile
TileId GetParent(this TileId tileId, IEnumerable<TileLevelOfDetail> levelsOfDetailToCheck) Calculate the id of the tile that is one level of detail up from this tile. This method will return Microsoft.Geospatial.TileId.Null if this tile has no parents.
String GetQuadKey(this TilePosition tilePosition) Creates the quad key string for the TilePosition.
void GetRelativeOffsetScale(this TileId childTileId, TileId parentTile, Single& offsetScaleX, Single& offsetScaleY, Single& childScale) Gets the normalized extent of this tile within the given parent tile.
Byte GetSubdomain(this TileId tile) Gets the subdomain of the tile, a value between 0 and 3. This id is relative to the parent tile. 0 is the first child, etc.
Boolean IsParentOf(this TilePosition tilePosition, TilePosition otherTilePosition) Returns true if the TilePosition is a parent of the specified TilePosition.
void PopulateCoveredTilePositionsList(MercatorBoundingBox boundingBox, TileLevelOfDetail levelOfDetail, List<TilePosition> tilePositionList) Populates the tilePositionList passed in with a list of TilePositions that cover the specified MercatorBoundingBox at the given level of detail. The list starts in the upper left tile and ends at the lower right tile.
GeoBoundingBox ToGeoBoundingBox(this TilePosition tilePosition) Converts the specified TilePosition to a Box.
MercatorBoundingBox ToMercatorBoundingBox(this TileId tileId) Converts the specified TileId to a MercatorBoundingBox.
MercatorBoundingBox ToMercatorBoundingBox(this TilePosition tilePosition) Converts the specified TileId to a MercatorBoundingBox.
TileId ToTileId(this TilePosition tilePosition) Calculates the Microsoft.Geospatial.TileId from a Microsoft.Geospatial.TilePosition.
TilePosition ToTilePosition(this TileId tileId, TileLevelOfDetail levelOfDetail) Calculates our position using the specified level of detail rather than going to the trouble of extracting ours.
TilePosition ToTilePosition(this TileId tileId) Calculates our position using the specified level of detail rather than going to the trouble of extracting ours.
Boolean TryGetChildren(this TileId tileId, IEnumerable<TileLevelOfDetail> levelsOfDetailToCheck, TileId[]& children) Calculate the children TileIds that have valid Lod from the current TileId.
Boolean TryGetParent(this TileId tileId, IEnumerable<TileLevelOfDetail> levelsOfDetailToCheck, TileId& parent) Try to calculate the id of the tile that is one level of detail up from this tile, on condition that this parent tile is a valid Lod. If not, keep getting the grand parents till finding one with valid lod.
Boolean TryGetParent(this TileId tileId, TileLevelOfDetail validLevelOfDetail, TileId& parent) Try to calculate the id of the tile that is one level of detail up from this tile, on condition that this parent tile is a valid Lod. If not, keep getting the grand parents till finding one with valid lod.
Boolean TryGetParent(this TilePosition tilePosition, Int16 delta, TilePosition& parentTilePosition) Try to calculate the id of the tile that is one level of detail up from this tile, on condition that this parent tile is a valid Lod. If not, keep getting the grand parents till finding one with valid lod.

TilePosition

The position of a Microsoft.Geospatial.TileId within a specific Microsoft.Geospatial.TileLevelOfDetail of tiles. This is an alternate, more verbose, expression of a single tile's Id.

public struct Microsoft.Geospatial.TilePosition
    : IEquatable<TilePosition>

Properties

Type Name Summary
TileLevelOfDetail LevelOfDetail Gets or sets the level of detail for this position.
Int32 X Gets or sets the horizontal offset for this position.
Int32 Y Gets or sets the vertical offset for this position.

Methods

Type Name Summary
Boolean Equals(Object obj) Overrides System.Object.Equals(System.Object).
Boolean Equals(TilePosition other) Overrides System.Object.Equals(System.Object).
Int32 GetHashCode() Overrides System.Object.GetHashCode.
String ToString()

Clone this wiki locally