jonas-p / go-shp

Go library for reading and writing ESRI Shapefiles. Pure Golang implementation based on the ESRI Shapefile technical description.
MIT License
255 stars 67 forks source link

Added support to load from memory #36

Open racerxdl opened 5 years ago

racerxdl commented 5 years ago

I added support to load a shapefile from memory. This way if you store the shp/dbf files using go-bindata then you can load it using byte arrays.

    shpFileData, err := ImageData.Asset("ne_50m_admin_0_countries.shp")
    if err != nil {
        panic(err)
    }
    dbfFileData, err := ImageData.Asset("ne_50m_admin_0_countries.dbf")
    if err != nil {
        panic(err)
    }
    shape, err := shp.OpenFromMemory(shpFileData, dbfFileData)
    if err != nil {
        return err, nil
    }
    defer shape.Close()
codecov-io commented 5 years ago

Codecov Report

Merging #36 into master will increase coverage by 0.12%. The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #36      +/-   ##
==========================================
+ Coverage   60.04%   60.17%   +0.12%     
==========================================
  Files           7        7              
  Lines         801      816      +15     
==========================================
+ Hits          481      491      +10     
- Misses        264      269       +5     
  Partials       56       56
Impacted Files Coverage Δ
reader.go 61.64% <55.55%> (+0.57%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c721ed4...dc51776. Read the comment docs.