本文整理匯總了Golang中github.com/paulsmith/gogeos/geos.Geometry.Envelope方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geometry.Envelope方法的具體用法?Golang Geometry.Envelope怎麽用?Golang Geometry.Envelope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/paulsmith/gogeos/geos.Geometry
的用法示例。
在下文中一共展示了Geometry.Envelope方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetBoundingBox
//GetBoundingBox computes the bounding box for a given geometry
func GetBoundingBox(g *geos.Geometry) (geographic.BoundingBox, error) {
bbox := geographic.BoundingBox{}
envelope, err := g.Envelope()
if err != nil {
return bbox, err
}
envelope, err = envelope.Shell()
if err != nil {
return bbox, err
}
centroid, err := envelope.Centroid()
if err != nil {
return bbox, err
}
bbox.LatitudeMinDeg, _ = centroid.Y()
bbox.LongitudeMinDeg, _ = centroid.X()
bbox.LatitudeMaxDeg = bbox.LatitudeMinDeg
bbox.LongitudeMaxDeg = bbox.LongitudeMinDeg
npoints, err := envelope.NPoint()
if err != nil {
return bbox, err
}
for i := 0; i < npoints; i++ {
pt := geos.Must(envelope.Point(i))
lon, _ := pt.X()
lat, _ := pt.Y()
if lon < bbox.LongitudeMinDeg {
bbox.LongitudeMinDeg = lon
}
if lon > bbox.LongitudeMaxDeg {
bbox.LongitudeMaxDeg = lon
}
if lat < bbox.LatitudeMinDeg {
bbox.LatitudeMinDeg = lat
}
if lat > bbox.LatitudeMaxDeg {
bbox.LatitudeMaxDeg = lat
}
}
return bbox, nil
}
示例2: envelope
func envelope(g *geos.Geometry) Envelope {
env, err := g.Envelope()
if err != nil {
log.Fatal(err)
}
ring, err := env.ExteriorRing()
if err != nil {
log.Fatal(err)
}
cs, err := ring.coordSeq()
if err != nil {
log.Fatal(err)
}
getX := getOrd(cs, (*geos.CoordSeq).GetX)
getY := getOrd(cs, (*geos.CoordSeq).GetY)
return Env(getX(0), getY(0), getX(2), getY(2))
}
示例3: RtreeBboxg
// Returns the bounding box of the geos.Geometry as a rtreego.Rect
func RtreeBboxg(g *geos.Geometry, tol float64) (*rtreego.Rect, error) {
env, err := g.Envelope()
if err != nil {
return nil, err
}
shell, _ := env.Shell()
if err != nil {
return nil, err
}
c, err := shell.Coords()
if err != nil {
return nil, err
}
return rtreego.NewRect(rtreego.Point{c[0].X, c[0].Y},
[]float64{math.Max(tol, c[2].X-c[0].X),
math.Max(tol, c[2].Y-c[0].Y)})
}