Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundingBox ¶
BoundingBox of the shape file.
func DecodeBoundingBox ¶
func DecodeBoundingBox(buf []byte) (BoundingBox, error)
DecodeBoundingBox decodes the bounding box coordinates.
func DecodeBoundingBoxP ¶
func DecodeBoundingBoxP(buf []byte, precision uint) (BoundingBox, error)
DecodeBoundingBoxP decodes the bounding box coordinates with a specified precision.
func (BoundingBox) String ¶
func (b BoundingBox) String() string
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error describes an error that occured when parsing a shape.
type Header ¶
type Header struct { FileLength uint32 Version uint32 ShapeType ShapeType BoundingBox BoundingBox }
Header represents a shp header.
type Option ¶
type Option func(*config)
Option funcs can be passed to NewScanner().
func PointPrecision ¶
PointPrecision sets the precision of coordinates.
type Point ¶
Point is a single pair of X and Y coordinates.
func DecodePoint ¶
DecodePoint decodes a single point shape.
func DecodePointP ¶
DecodePointP decodes a single point shape with specified precision.
func (Point) GeoJSONFeature ¶
func (p Point) GeoJSONFeature() *geojson.Feature
GeoJSONFeature creates a GeoJSON Point from a Shapefile Point.
func (Point) RecordNumber ¶
RecordNumber returns the position in the shape file.
type Polygon ¶
type Polygon Polyline
Polygon has the same syntax as a Polyline, but the parts should be unbroken rings.
func DecodePolygon ¶
DecodePolygon decodes a single polygon shape, but does not validate its complicance with the spec.
func DecodePolygonP ¶
DecodePolygonP decodes a single polygon shape with the specified precision, but does not validate its complicance with the spec.
func (Polygon) GeoJSONFeature ¶
func (p Polygon) GeoJSONFeature() *geojson.Feature
GeoJSONFeature creates a GeoJSON Polygon from a Shapefile Polygon.
func (Polygon) RecordNumber ¶
RecordNumber returns the position in the shape file.
type Polyline ¶
type Polyline struct { BoundingBox BoundingBox Parts []Part // contains filtered or unexported fields }
Polyline is an ordered set of verticies that consists of one or more parts, where a part is one or more Point.
func DecodePolyline ¶
DecodePolyline parses a single polyline shape, but does not validate its complicance with the spec.
func DecodePolylineP ¶
DecodePolylineP parses a single polyline shape with the specified precision, but does not validate its complicance with the spec.
func (Polyline) GeoJSONFeature ¶
func (p Polyline) GeoJSONFeature() *geojson.Feature
GeoJSONFeature creates a GeoJSON MultiLineString from a Shapefile Polyline.
func (Polyline) RecordNumber ¶
RecordNumber returns the position in the shape file.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner parses a shp file.
func NewScanner ¶
NewScanner creates a new Scanner for the supplied source.
func (*Scanner) AddOptions ¶
AddOptions to scanner after creation.
func (*Scanner) Err ¶
Err returns the first error encountered when parsing records. It should be called after calling the Shape method for the last time.
func (*Scanner) Scan ¶
Scan starts reading the shp file. Shapes can be accessed from the Shape method. An error is returned if there's a problem parsing the header. Errors that are encountered when parsing records must be checked with the Err method.
type Shape ¶
type Shape interface { Type() ShapeType RecordNumber() uint32 Validate(Validator) error GeoJSONFeature() *geojson.Feature // contains filtered or unexported methods }
Shape provides common information for all shapes of any type.
type ShapeType ¶
type ShapeType uint
ShapeType represents a shape type in the shp file.
const ( // Null shapes are allowed in any shp file, regardless of the type specified in the header. NullType ShapeType = 0 PointType ShapeType = 1 PolylineType ShapeType = 3 PolygonType ShapeType = 5 MultiPointType ShapeType = 8 PointZType ShapeType = 11 PolylineZType ShapeType = 13 PolygonZType ShapeType = 15 MultiPointZType ShapeType = 18 PointMType ShapeType = 21 PolylineMType ShapeType = 23 PolygonMType ShapeType = 25 MultiPointMType ShapeType = 28 MultiPatchType ShapeType = 31 )
Valid shape types. All shapes in a single shp file must be of the same type.
type Shapes ¶
type Shapes []Shape
Shapes represents a collection of shapes.
func (Shapes) BoundingBox ¶
func (s Shapes) BoundingBox() BoundingBox
BoundingBox returns the bounding box that encompasses all shapes.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is used to validate shapes inside a shp file.
func MakeValidator ¶
func MakeValidator(box BoundingBox) (Validator, error)
MakeValidator creates a new Validator based on the constraints of a particular shp file.