Coder Social home page Coder Social logo

go-shp's People

Contributors

ctessum avatar davidreynolds avatar fawick avatar icholy avatar jonas-p avatar leonnemets avatar peterstace avatar tdilo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-shp's Issues

dbf file extention is error

source code : w.dbf, err = os.Create(w.filename + "dbf")
can be modified w.dbf, err = os.Create(w.filename + ".dbf")

ZIPReader should make less assumptions on file name

(idea originally by @tdilo)

At the moment OpenZip assumes that the shapefile lies in the root of the archived filetree and has the same basename as the archive file.

The idea is to lift the restriction by scanning through the archive and using the relative path and basename of the first found shapefile.

ZipReader and GeometryType

It's possible to know the geometry type of the shapes read from a zip file? There is a technical reason for the missing of GeomtryType attribute in the SequentialReader interface?

Create SemVer releases

go-shp should start making releases that according to Semantic Versioning so that dep can be used more naturally.

Add spatial index

I suggested go-shp to be used as a geometry provider in the vector tile server Tegola here: go-spatial/tegola#160

They were open to the idea and suggested that go-shp implemented a spatial index. This issue is meant to keep track of that.

Reading Multipolygon Shapes

In a shp file that I have we have type ""type": called multipolygon.
"Feature","geometry":{"type":"MultiPolygon","coordinates":"
What is the best way to read this? When I do *shp.Polygon I am only able to retrieve one of the polygons and its bbx.

get attribute exception

I use this lib to read the shapefile.DBF and store it as a map Attribute. when I try to get the Value of I had stored, I get nil,I use value,ok := Attribute["OBJECTID"],it return nil,false.I store it like this:

for indFields, v := range fields {
	featureAttributes[v.String()] = shpreader.Attribute(indFields)
}

And when I do it like this:

func (f Feature) GetAttrByName(name string) string {
	for k, v := range f.Attributes {
		if k == name {
			return v
		}
	}
	mylog.Error.Printf("获取%s的值失败", name)
	return ""
}

it can work again.just slightly perplexed.Why is that?

func TestZipReader(t *testing.T) {}

Out of the box TestZipReader doens't seem to be working

--- FAIL: TestZipReader (0.01s)
        zipreader_test.go:75: Testing zipped reading for test_files/polyline
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/polyline read was wrong. Wanted 2, got 1.
        zipreader_test.go:75: Testing zipped reading for test_files/multipoint
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/multipoint read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/polylinez
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/polylinez read was wrong. Wanted 2, got 1.
        zipreader_test.go:75: Testing zipped reading for test_files/multipatch
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/multipatch read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/polygonz
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/polygonz read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/polylinem
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/polylinem read was wrong. Wanted 2, got 1.
        zipreader_test.go:75: Testing zipped reading for test_files/polygonm
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/polygonm read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/point
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/point read was wrong. Wanted 3, got 2.
        zipreader_test.go:75: Testing zipped reading for test_files/pointz
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/pointz read was wrong. Wanted 3, got 2.
        zipreader_test.go:75: Testing zipped reading for test_files/multipointz
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/multipointz read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/multipointm
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/multipointm read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/polygon
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/polygon read was wrong. Wanted 1, got 0.
        zipreader_test.go:75: Testing zipped reading for test_files/pointm
        zipreader_test.go:64: Error when iterating over the shapes: Error while reading next shape: EOF
        reader_test.go:220: Number of shapes for test_files/pointm read was wrong. Wanted 3, got 2.
FAIL
exit status 1
FAIL    github.com/gertcuykens/go-shp   0.029s
%```

Append shapefiles without creating a copy in memory

Hi Jonas, as far as I understand, we can open a shapefile or create one but not append to one

shape, err := shp.Open("static-segments/segments.shp")
shape, err := shp.Create("new-static-segments/segments.shp", shp.MULTIPOINT)

Can we have a shape, err := shp.Append("static-segments/segments.shp", shp.MULTIPOINT) ?

Thanks

Is this maintained?

@jonas-p are you still planning on maintaining this? if not some people in the community might want to fork it and address some the issues and prs.

Feature request: Support reading shp/shx/dbf bundles from a ZIP archive

I usually encounter shapefiles that come as a ZIP which contains the .shp/.shx/.dbf. It would be great to have the possibility of iterating over the shapes and the database without uncompressing the ZIP beforehand.

This might prove to be non-trivial, as the io.ReadCloser that is returned by zip.File.Open does not support seeking. It might be okay for the shapes, as they are read sequentially, anyway, but the random-access to the DBF will not be possible.

As the typical use case might be iterating over all shapes and their individual attributes, one might restrict the access to the attributes to the ones belonging to the last read shape.

I imagine something like a type ZipReader that has func (z *ZipReader) Next() and func (z *ZipReader) ShapeFields() (row int, shape Shape, fieldValues []string) which can be used in a loop in the same way the methods of shp.Reader are.

Internally Next() would read the .shp one shape and the .dbf one row at a time, with the latter internally buffered as a plain []byte-slice which is later interpreted in the same way by shp.ZipReader.ShapeFields as shp.Reader.ReadAttribute does with the single attributes now.

Off by one error in *reader.Read

In the example in README.md, there is the code

// loop through all features in the shapefile
for shape.Next() {

but in (r *Reader) Next() you return false if the file hits EOF, meaning the last item in the file will not be read.

        r.shape.read(er)
	if er.e != nil {
		r.err = fmt.Errorf("Error while reading next shape: %v", er.e)
		return false
	}

image

I know some behaviour changed around EOF as error between go versions a while back (there was very briefly a similar issue in grpc) so I presume this has snuck in that way.

Why is it challenging to manipulate points when working with zipped shapefiles in Go?

     shape, _ := shp.OpenZip(tmpFile.Name())
     defer shape.Close()
     for shape.Next() {
	_, p := shape.Shape()
	if point, ok := p.(*shp.Polygon); ok {
		fmt.Println(point.Points)
	}
}

Why do I have to write it as p(shp.Polygon)? I want to be able to write p.Points() directly.
It seems like I have to spend time understanding the internal structure and designing according to what I need

return r.bbox for Writer

I think the writer should also have a method to return the final BBox like the Reader does

func (r *Reader) BBox() Box {
	return r.bbox
}

r.Shape() returns illegal row number

I use this library to navigate through a shape file containing a road network (made out of polylines). After the r.Next() call the function Shape() returns the row number -1. This results into endless loops and makes the library useless for any file reading. Are there already known situations this habit appeared? Do you have any solutions?
The road network has been created from a filtered OSM-file using QGIS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.