...

Package shp

import "github.com/reearth/reearth-backend/pkg/shp"
Overview
Index

Overview ▾

Index ▾

type Box
    func BBoxFromPoints(points []Point) (box Box)
    func (b *Box) Extend(box Box)
    func (b *Box) ExtendWithPoint(p Point)
type Field
type MultiPatch
    func (p MultiPatch) BBox() Box
type MultiPoint
    func (p MultiPoint) BBox() Box
type MultiPointM
    func (p MultiPointM) BBox() Box
type MultiPointZ
    func (p MultiPointZ) BBox() Box
type Null
    func (n Null) BBox() Box
type Point
    func (p Point) BBox() Box
type PointM
    func (p PointM) BBox() Box
type PointZ
    func (p PointZ) BBox() Box
type PolyLine
    func NewPolyLine(parts [][]Point) *PolyLine
    func (p PolyLine) BBox() Box
type PolyLineM
    func (p PolyLineM) BBox() Box
type PolyLineZ
    func (p PolyLineZ) BBox() Box
type Polygon
    func (p Polygon) BBox() Box
type PolygonM
    func (p PolygonM) BBox() Box
type PolygonZ
    func (p PolygonZ) BBox() Box
type Reader
    func ReadFrom(r io.Reader) (*Reader, error)
    func (r *Reader) BBox() Box
    func (r *Reader) Err() error
    func (r *Reader) Next() bool
    func (r *Reader) Shape() (int, Shape)
type SequentialReader
    func SequentialReaderFromExt(shp io.ReadCloser) SequentialReader
type Shape
type ShapeType
    func (i ShapeType) String() string
type Writer
    func CreateFrom(ws io.WriteSeeker, t ShapeType) (*Writer, error)
    func (w *Writer) Close() error
    func (w *Writer) Write(shape Shape) (int32, error)
type ZipReader
    func ReadZipFrom(r io.Reader) (*ZipReader, error)
    func (zr *ZipReader) Close() error
    func (zr *ZipReader) Err() error
    func (zr *ZipReader) Next() bool
    func (zr *ZipReader) Shape() (int, Shape)

Package files

errreader.go reader.go sequentialreader.go shapefile.go shapetype_string.go writer.go zipreader.go

type Box

Box structure made up from four coordinates. This type is used to represent bounding boxes

type Box struct {
    MinX, MinY, MaxX, MaxY float64
}

func BBoxFromPoints

func BBoxFromPoints(points []Point) (box Box)

BBoxFromPoints returns the bounding box calculated from points.

func (*Box) Extend

func (b *Box) Extend(box Box)

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

func (b *Box) ExtendWithPoint(p Point)

ExtendWithPoint extends box with coordinates from point if they are outside the range of the current box.

type Field

Field representation of a field object in the DBF file

type Field struct {
    Name      [11]byte
    Fieldtype byte
    Addr      [4]byte // not used
    Size      uint8
    Precision uint8
    Padding   [14]byte
}

type MultiPatch

MultiPatch consists of a number of surfaces patches. Each surface path descries a surface. The surface patches of a MultiPatch are referred to as its parts, and the type of part controls how the order of vertices of an MultiPatch part is interpreted.

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
}

func (MultiPatch) BBox

func (p MultiPatch) BBox() Box

BBox returns the bounding box of the MultiPatch feature

type MultiPoint

MultiPoint is the shape that consists of multiple points.

type MultiPoint struct {
    Box       Box
    NumPoints int32
    Points    []Point
}

func (MultiPoint) BBox

func (p MultiPoint) BBox() Box

BBox returns the bounding box of the MultiPoint feature

type MultiPointM

MultiPointM is the collection of multiple points with measures.

type MultiPointM struct {
    Box       Box
    NumPoints int32
    Points    []Point
    MRange    [2]float64
    MArray    []float64
}

func (MultiPointM) BBox

func (p MultiPointM) BBox() Box

BBox eturns the bounding box of the MultiPointM feature

type MultiPointZ

MultiPointZ consists of one ore more PointZ.

type MultiPointZ struct {
    Box       Box
    NumPoints int32
    Points    []Point
    ZRange    [2]float64
    ZArray    []float64
    MRange    [2]float64
    MArray    []float64
}

func (MultiPointZ) BBox

func (p MultiPointZ) BBox() Box

BBox eturns the bounding box of the MultiPointZ feature.

type Null

Null is an empty shape.

type Null struct {
}

func (Null) BBox

func (n Null) BBox() Box

BBox Returns an empty BBox at the geometry origin.

type Point

Point is the shape that consists of single a geometry point.

type Point struct {
    X, Y float64
}

func (Point) BBox

func (p Point) BBox() Box

BBox returns the bounding box of the Point feature, i.e. an empty area at the point location itself.

type PointM

PointM is a point with a measure.

type PointM struct {
    X float64
    Y float64
    M float64
}

func (PointM) BBox

func (p PointM) BBox() Box

BBox returns the bounding box of the PointM feature which is a zero-sized area at the X- and Y-coordinates of the point.

type PointZ

PointZ is a triplet of double precision coordinates plus a measure.

type PointZ struct {
    X float64
    Y float64
    Z float64
    M float64
}

func (PointZ) BBox

func (p PointZ) BBox() Box

BBox eturns the bounding box of the PointZ feature which is an zero-sized area at the X and Y coordinates of the feature.

type PolyLine

PolyLine is a shape type that consists of an ordered set of vertices that consists of one or more parts. A part is a connected sequence of two ore more points. Parts may or may not be connected to another and may or may not intersect each other.

type PolyLine struct {
    Box
    NumParts  int32
    NumPoints int32
    Parts     []int32
    Points    []Point
}

func NewPolyLine

func NewPolyLine(parts [][]Point) *PolyLine

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.

func (PolyLine) BBox

func (p PolyLine) BBox() Box

BBox returns the bounding box of the PolyLine feature

type PolyLineM

PolyLineM is the polyline in which each point also has a measure.

type PolyLineM struct {
    Box       Box
    NumParts  int32
    NumPoints int32
    Parts     []int32
    Points    []Point
    MRange    [2]float64
    MArray    []float64
}

func (PolyLineM) BBox

func (p PolyLineM) BBox() Box

BBox returns the bounding box of the PolyLineM feature.

type PolyLineZ

PolyLineZ is a shape which consists of one or more parts. A part is a connected sequence of two or more points. Parts may or may not be connected and may or may not intersect one another.

type PolyLineZ struct {
    Box       Box
    NumParts  int32
    NumPoints int32
    Parts     []int32
    Points    []Point
    ZRange    [2]float64
    ZArray    []float64
    MRange    [2]float64
    MArray    []float64
}

func (PolyLineZ) BBox

func (p PolyLineZ) BBox() Box

BBox eturns the bounding box of the PolyLineZ feature.

type Polygon

Polygon is identical to the PolyLine struct. However the parts must form rings that may not intersect.

type Polygon PolyLine

func (Polygon) BBox

func (p Polygon) BBox() Box

BBox returns the bounding box of the Polygon feature

type PolygonM

PolygonM structure is identical to the PolyLineZ structure.

type PolygonM PolyLineZ

func (PolygonM) BBox

func (p PolygonM) BBox() Box

BBox returns the bounding box of the PolygonM feature.

type PolygonZ

PolygonZ structure is identical to the PolyLineZ structure.

type PolygonZ PolyLineZ

func (PolygonZ) BBox

func (p PolygonZ) BBox() Box

BBox returns the bounding box of the PolygonZ feature

type Reader

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.

type Reader struct {
    GeometryType ShapeType
    // contains filtered or unexported fields
}

func ReadFrom

func ReadFrom(r io.Reader) (*Reader, error)

ReadFrom read from io.Reader

func (*Reader) BBox

func (r *Reader) BBox() Box

BBox returns the bounding box of the shapefile.

func (*Reader) Err

func (r *Reader) Err() error

Err returns the last non-EOF error encountered.

func (*Reader) Next

func (r *Reader) Next() bool

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 or encounters an error.

func (*Reader) Shape

func (r *Reader) Shape() (int, Shape)

Shape returns the most recent feature that was read by a call to Next. It returns two values, the int is the object index starting from zero in the shapefile which can be used as row in ReadAttribute, and the Shape is the object.

type SequentialReader

SequentialReader is the interface that allows reading shapes and attributes one after another. It also embeds io.Closer.

type SequentialReader interface {
    // Closer 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)

    // Err returns the last non-EOF error encountered.
    Err() error
}

func SequentialReaderFromExt

func SequentialReaderFromExt(shp 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

Shape interface

type Shape interface {
    BBox() Box
    // contains filtered or unexported methods
}

type ShapeType

ShapeType is a identifier for the the type of shapes.

type ShapeType int32

These are the possible shape types.

const (
    NULL        ShapeType = 0
    POINT       ShapeType = 1
    POLYLINE    ShapeType = 3
    POLYGON     ShapeType = 5
    MULTIPOINT  ShapeType = 8
    POINTZ      ShapeType = 11
    POLYLINEZ   ShapeType = 13
    POLYGONZ    ShapeType = 15
    MULTIPOINTZ ShapeType = 18
    POINTM      ShapeType = 21
    POLYLINEM   ShapeType = 23
    POLYGONM    ShapeType = 25
    MULTIPOINTM ShapeType = 28
    MULTIPATCH  ShapeType = 31
)

func (ShapeType) String

func (i ShapeType) String() string

type Writer

Writer is the type that is used to write a new shapefile.

type Writer struct {
    GeometryType ShapeType
    // contains filtered or unexported fields
}

func CreateFrom

func CreateFrom(ws io.WriteSeeker, t ShapeType) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

Close closes the writer.

func (*Writer) Write

func (w *Writer) Write(shape Shape) (int32, error)

Write shape to the writer. Returns the index of the written object which can be used in WriteAttribute.

type ZipReader

ZipReader provides an interface for reading Shapefiles that are compressed in a ZIP archive.

type ZipReader struct {
    // contains filtered or unexported fields
}

func ReadZipFrom

func ReadZipFrom(r io.Reader) (*ZipReader, error)

ReadZipFrom read zip file from io.Reader, zip file must contain only one shape file

func (*ZipReader) Close

func (zr *ZipReader) Close() error

Close closes the ZipReader and frees the allocated resources.

func (*ZipReader) Err

func (zr *ZipReader) Err() error

Err returns the last non-EOF error that was encountered by this ZipReader.

func (*ZipReader) Next

func (zr *ZipReader) Next() bool

Next reads the next shape in the shapefile and the next row in the DBF. Call Shape() and Attribute() to access the values.

func (*ZipReader) Shape

func (zr *ZipReader) Shape() (int, Shape)

Shape returns the shape that was last read as well as the current index.