github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/geo/geopb/types.go (about)

     1  // Copyright 2020 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package geopb
    12  
    13  // The following are the common standard SRIDs that we support.
    14  const (
    15  	// UnknownSRID is the default SRID if none is provided.
    16  	UnknownSRID = SRID(0)
    17  	// DefaultGeometrySRID is the same as being unknown.
    18  	DefaultGeometrySRID = UnknownSRID
    19  	// DefaultGeographySRID (aka 4326) is the GPS lat/lng we all know and love.
    20  	// In this system, (long, lat) corresponds to (X, Y), bounded by
    21  	// ([-180, 180], [-90 90]).
    22  	DefaultGeographySRID = SRID(4326)
    23  )
    24  
    25  const (
    26  	// ZShapeTypeFlag indicates a Z dimension on the ShapeType.
    27  	ZShapeTypeFlag = 1 << 30
    28  	// MShapeTypeFlag indicates a M dimension on the ShapeType.
    29  	MShapeTypeFlag = 1 << 29
    30  )
    31  
    32  // To2D returns the ShapeType for the corresponding 2D geometry type.
    33  func (s ShapeType) To2D() ShapeType {
    34  	return ShapeType(uint32(s) & (MShapeTypeFlag - 1))
    35  }
    36  
    37  // SRID is a Spatial Reference Identifer. All geometry and geography shapes are
    38  // stored and represented as using coordinates that are bare floats. SRIDs tie these
    39  // floats to the planar or spherical coordinate system, allowing them to be interpreted
    40  // and compared.
    41  //
    42  // The zero value is special and means an unknown coordinate system.
    43  type SRID int32
    44  
    45  // WKT is the Well Known Text form of a spatial object.
    46  type WKT string
    47  
    48  // EWKT is the Extended Well Known Text form of a spatial object.
    49  type EWKT string
    50  
    51  // WKB is the Well Known Bytes form of a spatial object.
    52  type WKB []byte
    53  
    54  // EWKB is the Extended Well Known Bytes form of a spatial object.
    55  type EWKB []byte