Documentation
¶
Index ¶
- Constants
- func AttributeCount(sr SequentialReader) int
- func Attributes(sr SequentialReader) []string
- type Box
- type Field
- type MultiPatch
- type MultiPoint
- type MultiPointM
- type MultiPointZ
- type Null
- type Point
- type PointM
- type PointZ
- type PolyLine
- type PolyLineM
- type PolyLineZ
- type Polygon
- type PolygonM
- type PolygonZ
- type Reader
- func (r *Reader) Attribute(n int) string
- func (r *Reader) AttributeCount() int
- func (r *Reader) BBox() Box
- func (r *Reader) Close() error
- func (r *Reader) Err() error
- func (r *Reader) Fields() []Field
- func (r *Reader) Next() bool
- func (r *Reader) ReadAttribute(row int, field int) string
- func (r *Reader) Shape() (int, Shape)
- type SequentialReader
- type Shape
- type ShapeType
- type Writer
- type ZipReader
Constants ¶
const ( NULL ShapeType = 0 POINT = 1 POLYLINE = 3 POLYGON = 5 MULTIPOINT = 8 POINTZ = 11 POLYLINEZ = 13 POLYGONZ = 15 MULTIPOINTZ = 18 POINTM = 21 POLYLINEM = 23 POLYGONM = 25 MULTIPOINTM = 28 MULTIPATCH = 31 )
Variables ¶
This section is empty.
Functions ¶
func AttributeCount ¶
func AttributeCount(sr SequentialReader) int
AttributeCount returns the number of fields of the database.
func Attributes ¶
func Attributes(sr SequentialReader) []string
Attributes() returns all attributes of the shape that sr was last advanced to.
Types ¶
type Box ¶
type Box struct {
MinX, MinY, MaxX, MaxY float64
}
Box structure made up from four coordinates. This type is used to represent bounding boxes
func BBoxFromPoints ¶
BBoxFromPoints returns the bounding box calculated from points.
func (*Box) Extend ¶
Extend extends the box with coordinates from the provided box. This method calls Box.ExtendWithPoint twice with {MinX, MinY} and {MaxX, MaxY}
func (*Box) ExtendWithPoint ¶
ExtendWithPoint extends box with coordinates from point if they are outside the range of the current box.
type Field ¶
type Field struct {
Name [11]byte
Fieldtype byte
Addr [4]byte // not used
Size uint8
Precision uint8
Padding [14]byte
}
Field representation of a field object in the DBF file
func DateField ¶
Returns a DateField that can be used in SetFields to initialize the DBF file. Used to store Date strings formatted as YYYYMMDD. Data wise this is the same as a StringField with length 8.
func FloatField ¶
Returns a FloatField that can be used in SetFields to initialize the DBF file. Used to store floating points with precision in the DBF.
func NumberField ¶
Returns a NumberField that can be used in SetFields to initialize the DBF file.
func StringField ¶
Returns a StringField that can be used in SetFields to initialize the DBF file.
type MultiPatch ¶
type MultiPatch struct {
Box Box
NumParts int32
NumPoints int32
Parts []int32
PartTypes []int32
Points []Point
ZRange [2]float64
ZArray []float64
MRange [2]float64
MArray []float64
}
Shapefile MultiPatch type
func (MultiPatch) BBox ¶
func (p MultiPatch) BBox() Box
Returns the bounding box of the MultiPatch feature
type MultiPoint ¶
Shapefile MultiPoint type
func (MultiPoint) BBox ¶
func (p MultiPoint) BBox() Box
Returns the bounding box of the MultiPoint feature
type MultiPointM ¶
type MultiPointM struct {
Box Box
NumPoints int32
Points []Point
MRange [2]float64
MArray []float64
}
Shapefile MultiPointM type
func (MultiPointM) BBox ¶
func (p MultiPointM) BBox() Box
Returns the bounding box of the MultiPointM feature
type MultiPointZ ¶
type MultiPointZ struct {
Box Box
NumPoints int32
Points []Point
ZRange [2]float64
ZArray []float64
MRange [2]float64
MArray []float64
}
Shapefile MultiPointZ type
func (MultiPointZ) BBox ¶
func (p MultiPointZ) BBox() Box
Returns the bounding box of the MultiPointZ feature
type PolyLine ¶
Shapefile PolyLine type
func NewPolyLine ¶
NewPolyLine returns a pointer a new PolyLine created with the provided points. The inner slice should be the points that the parent part consists of.
type PolyLineM ¶
type PolyLineM struct {
Box Box
NumParts int32
NumPoints int32
Parts []int32
Points []Point
MRange [2]float64
MArray []float64
}
Shapefile PolyLineM type
type PolyLineZ ¶
type PolyLineZ struct {
Box Box
NumParts int32
NumPoints int32
Parts []int32
Points []Point
ZRange [2]float64
ZArray []float64
MRange [2]float64
MArray []float64
}
Shapefile PolyLineZ type
type Polygon ¶
type Polygon PolyLine
Shapefile Polygon type The Polygon structure is identical to the PolyLine structure
type PolygonM ¶
type PolygonM PolyLineZ
Shapefile PolygonM type The PolygonZ structure is identical to the PolyLineZ structure
type PolygonZ ¶
type PolygonZ PolyLineZ
Shapefile PolygonZ type The PolygonZ structure is identical to the PolyLineZ structure
type Reader ¶
type Reader struct {
GeometryType ShapeType
// contains filtered or unexported fields
}
Reader provides a interface for reading Shapefiles. Calls to the Next method will iterate through the objects in the Shapefile. After a call to Next the object will be available through the Shape method.
func (*Reader) Attribute ¶
Attribute returns value of the n-th attribute of the most recent feature that was read by a call to Next.
func (*Reader) AttributeCount ¶
AttributeCount returns number of records in the DBF table.
func (*Reader) Next ¶
Next reads in the next Shape in the Shapefile, which will then be available through the Shape method. It returns false when the reader has reached the end of the file.
func (*Reader) ReadAttribute ¶
ReadAttribute returns the attribute value at row for field in the DBF table as a string. Both values starts at 0.
type SequentialReader ¶
type SequentialReader interface {
// Close() frees the resources allocated by the SequentialReader.
io.Closer
// Next() tries to advance the reading by one shape and one attribute row
// and returns true if the read operation could be performed without any
// error.
Next() bool
// Shape returns the index and the last read shape. If the SequentialReader
// encountered any errors, nil is returned for the Shape.
Shape() (int, Shape)
// Attribute returns the value of the n-th attribute in the current row. If
// the SequentialReader encountered any errors, the empty string is
// returned.
Attribute(n int) string
// Fields returns the fields of the database. If the SequentialReader
// encountered any errors, nil is returned.
Fields() []Field
// Err returns the last non-EOF error encountered.
Err() error
}
SequentialReader is the interface that allows reading shapes and attributes one after another. It also embeds io.Closer.
func SequentialReaderFromExt ¶
func SequentialReaderFromExt(shp, dbf io.ReadCloser) SequentialReader
SequentialReaderFromExt returns a new SequentialReader that interprets shp as a source of shapes whose attributes can be retrieved from dbf.
type Shape ¶
type Shape interface {
BBox() Box
// contains filtered or unexported methods
}
Shape interface
type Writer ¶
type Writer struct {
GeometryType ShapeType
// contains filtered or unexported fields
}
func Create ¶
Creates a new Shapefile. This also creates a corresponding SHX file. It is important to use Close() when done because that method writes all the headers for each file (SHP, SHX and DBF).
func (*Writer) Close ¶
func (w *Writer) Close()
Closes the Shapefile. This must be used at the end of the transaction because it writes the correct headers to the SHP/SHX and DBF files before closing.
func (*Writer) SetFields ¶
Set fields in the DBF. This initializes the DBF file and should be used prior to writing any attributes.
func (*Writer) Write ¶
Write shape to the Shapefile. This also creates a record in the SHX file and DBF file (if it is initialized). Returns the index of the written object which can be used in WriteAttribute.
func (*Writer) WriteAttribute ¶
Writes value for field at row in the DBF. Row number should be the same as the order the Shape was written to the Shapefile. The field value corresponds the the field in the splice used in SetFields.
type ZipReader ¶
type ZipReader struct {
// contains filtered or unexported fields
}
ZipReader provides an interface for reading Shapefiles that are compressed in a ZIP archive.
func OpenZip ¶
OpenZip opens a ZIP file that contains a shapefile. The path of the SHP and DBF file in the ZIP must be the same as the basename of the ZIP itself.
func (*ZipReader) Attribute ¶
Attribute returns the n-th field of the last row that was read. If there were any errors before, the empty string is returned.