-
Notifications
You must be signed in to change notification settings - Fork 11
Google.OpenLocationCode
Convert locations to and from convenient codes known as Open Location Codes or Plus Codes
Open Location Codes are short, ~10 character codes that can be used instead of street addresses. The codes can be generated and decoded offline, and use a reduced character set that minimises the chance of codes including words.
The Open Location Code API is implemented through the static methods.
public class Google.OpenLocationCode.OpenLocationCode| Name | Summary |
|---|---|
OpenLocationCode(String code) |
Creates an OpenLocationCode object for the provided full code (or CodeDigits). |
OpenLocationCode(Double latitude, Double longitude, Int32 codeLength = 10) |
Creates an OpenLocationCode object encoded from the provided latitude/longitude coordinates. |
OpenLocationCode(GeoPoint point, Int32 codeLength = 10) |
Creates an OpenLocationCode object encoded from the provided geographic point coordinates. |
| Type | Name | Summary |
|---|---|---|
String |
Code | The code which is a valid full Open Location Code (plus code). |
String |
CodeDigits | The digits of the full code which excludes the separator '+' character and any padding '0' characters. This is useful to more concisely represent or encode a full Open Location Code since the code digits can be normalized back into a valid full code. |
| Type | Name | Summary |
|---|---|---|
CodeArea |
Decode() | Decodes this full Open Location Code into a CodeArea object encapsulating the latitude/longitude coordinates of the area bounding box. |
Boolean |
IsPadded() | Determines if this full Open Location Code is padded which is defined by IsPadded(String code). |
ShortCode |
Shorten(Double referenceLatitude, Double referenceLongitude) |
Shorten this full Open Location Code by removing four or six digits (depending on the provided reference point). It removes as many digits as possible. |
ShortCode |
Shorten(GeoPoint referencePoint) |
Shorten this full Open Location Code by removing four or six digits (depending on the provided reference point). It removes as many digits as possible. |
Boolean |
Equals(Object obj) |
Determines whether the provided object is an OpenLocationCode with the same Code as this OpenLocationCode. |
Int32 |
GetHashCode() | Returns the hashcode of the Code string. |
String |
ToString() | Returns the Code string. |
| Type | Name | Summary |
|---|---|---|
Int32 |
CodePrecisionExtra | Provides an extra precision code, approximately 2x3 meters. |
Int32 |
CodePrecisionNormal | Provides a normal precision code, approximately 14x14 meters. |
| Type | Name | Summary |
|---|---|---|
Boolean |
IsValid(String code) |
Determines if the provided string is a valid Open Location Code sequence. A valid Open Location Code can be either full or short (XOR). |
Boolean |
IsShort(String code) |
Determines if a code is a valid short Open Location Code. A short Open Location Code is a sequence created by removing an even number of characters from the start of a full Open Location Code. Short codes must include the separator character and it must be before eight or less characters. |
Boolean |
IsFull(String code) |
Determines if a code is a valid full Open Location Code. Full codes must include the separator character and it must be after eight characters. |
Boolean |
IsPadded(String code) |
Determines if a code is a valid padded Open Location Code. An Open Location Code is padded when it has only 2, 4, or 6 valid digits followed by zero '0' as padding to form a full 8 digit code. If this returns true that the code is padded, then it is also implied to be full since short codes cannot be padded. |
String |
Encode(Double latitude, Double longitude, Int32 codeLength = 10) |
Encodes latitude/longitude coordinates into a full Open Location Code of the provided length. |
String |
Encode(GeoPoint point, Int32 codeLength = 10) |
Encodes geographic point coordinates into a full Open Location Code of the provided length. |
CodeArea |
Decode(String code) |
Decodes a full Open Location Code into a CodeArea object encapsulating the latitude/longitude coordinates of the area bounding box. |
ShortCode |
Shorten(String code, Double referenceLatitude, Double referenceLongitude) |
Shorten a full Open Location Code by removing four or six digits (depending on the provided reference point). It removes as many digits as possible. |
A square GeoArea for the coordinates of a decoded Open Location Code area.
public class Google.OpenLocationCode.CodeArea
: GeoArea| Type | Name | Summary |
|---|---|---|
Int32 |
CodeLength | The length of the decoded Open Location Code. |
A rectangular area on the geographic coordinate system specified by the minimum and maximum GeoPoint coordinates. The coordinates include the latitude and longitude of the lower left (south west) and upper right (north east) corners.
Additional properties exist to calculate the Center of the bounding box, and the LatitudeHeight or LongitudeWidth area dimensions in degrees.
public class Google.OpenLocationCode.GeoArea| Name | Summary |
|---|---|
GeoArea(GeoPoint min, GeoPoint max) |
Create a new rectangular GeoArea of the provided min and max geo points. |
GeoArea(Double southLatitude, Double westLongitude, Double northLatitude, Double eastLongitude) |
Create a new rectangular GeoArea of the provided min and max geo coordinates. |
| Type | Name | Summary |
|---|---|---|
GeoPoint |
Max | The max (north east) point coordinates of the area bounds. |
GeoPoint |
Min | The min (south west) point coordinates of the area bounds. |
GeoPoint |
Center | The center point of the area which is equidistant between Min and Max. |
Double |
LatitudeHeight | The height of the area in latitude degrees. |
Double |
LongitudeWidth | The width of the area in longitude degrees. |
Double |
EastLongitude | The east (max) longitude coordinate in decimal degrees. |
Double |
NorthLatitude | The north (max) latitude coordinate in decimal degrees. |
Double |
SouthLatitude | The south (min) latitude coordinate in decimal degrees. |
Double |
WestLongitude | The west (min) longitude coordinate in decimal degrees. |
Double |
CenterLatitude | The center latitude coordinate in decimal degrees. |
Double |
CenterLongitude | The center longitude coordinate in decimal degrees. |
| Type | Name | Summary |
|---|---|---|
Boolean |
Contains(GeoPoint point) |
Determines whether this GeoArea contains the provided point |
Boolean |
Contains(Double latitude, Double longitude) |
Determines whether this GeoArea contains the provided point |
A point on the geographic coordinate system specified by latitude and longitude coordinates in degrees.
public struct Google.OpenLocationCode.GeoPoint
: IEquatable<GeoPoint>| Name | Summary |
|---|---|
GeoPoint(Double latitude, Double longitude) |
Creates a GeoPoint value of the provided latitude and longitude coordinates. |
| Type | Name | Summary |
|---|---|---|
Double |
Latitude | The latitude coordinate in decimal degrees (y axis). |
Double |
Longitude | The longitude coordinate in decimal degrees (x axis). |
| Type | Name | Summary |
|---|---|---|
Boolean |
Equals(Object obj) |
Determines whether the provided object is a GeoPoint with the same Latitude and Longitude as this GeoPoint. |
Boolean |
Equals(GeoPoint other) |
Determines whether the provided GoePoint has the same Latitude and Longitude as this GeoPoint. |
Int32 |
GetHashCode() | The hash code of this GeoPoint coordinates. |
String |
ToString() | Returns a human readable representation of this GeoPoint. |