Sha256: 6009e231084ee233c0d60ea27d90abfe80dd52e87945d2d70ca350a4bf319c8d

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

package magic

import (
	"bytes"
	"encoding/binary"
)

// Shp matches a shape format file.
// https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
func Shp(raw []byte, limit uint32) bool {
	if len(raw) < 112 {
		return false
	}

	if !(binary.BigEndian.Uint32(raw[0:4]) == 9994 &&
		binary.BigEndian.Uint32(raw[4:8]) == 0 &&
		binary.BigEndian.Uint32(raw[8:12]) == 0 &&
		binary.BigEndian.Uint32(raw[12:16]) == 0 &&
		binary.BigEndian.Uint32(raw[16:20]) == 0 &&
		binary.BigEndian.Uint32(raw[20:24]) == 0 &&
		binary.LittleEndian.Uint32(raw[28:32]) == 1000) {
		return false
	}

	shapeTypes := []int{
		0,  // Null shape
		1,  // Point
		3,  // Polyline
		5,  // Polygon
		8,  // MultiPoint
		11, // PointZ
		13, // PolylineZ
		15, // PolygonZ
		18, // MultiPointZ
		21, // PointM
		23, // PolylineM
		25, // PolygonM
		28, // MultiPointM
		31, // MultiPatch
	}

	for _, st := range shapeTypes {
		if st == int(binary.LittleEndian.Uint32(raw[108:112])) {
			return true
		}
	}

	return false
}

// Shx matches a shape index format file.
// https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
func Shx(raw []byte, limit uint32) bool {
	return bytes.HasPrefix(raw, []byte{0x00, 0x00, 0x27, 0x0A})
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/gabriel-vasile/mimetype/internal/magic/geo.go