本文整理匯總了Golang中github.com/paulsmith/gogeos/geos.Geometry.NGeometry方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geometry.NGeometry方法的具體用法?Golang Geometry.NGeometry怎麽用?Golang Geometry.NGeometry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/paulsmith/gogeos/geos.Geometry
的用法示例。
在下文中一共展示了Geometry.NGeometry方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ToGjFeature
func ToGjFeature(g *geos.Geometry) (gjFeature, error) {
var gjf gjFeature
gjf.Type = "Feature"
gjf.Geometry.Type = "MultiPolygon"
ngeoms, _ := g.NGeometry()
gjf.Geometry.Coords = make([][][][]float64, ngeoms)
for i := 0; i < ngeoms; i++ {
subg, err := g.Geometry(i)
if err != nil {
return gjf, err
}
holes, err := subg.Holes()
if err != nil {
return gjf, err
}
gjf.Geometry.Coords[i] = make([][][]float64, 1+len(holes))
shell, err := subg.Shell()
if err != nil {
return gjf, err
}
coords, err := shell.Coords()
if err != nil {
return gjf, err
}
gjf.Geometry.Coords[i][0] = make([][]float64, len(coords))
for j, coord := range coords {
gjf.Geometry.Coords[i][0][j] = make([]float64, 2)
gjf.Geometry.Coords[i][0][j][0] = coord.X
gjf.Geometry.Coords[i][0][j][1] = coord.Y
}
for k, hole := range holes {
coords, err := hole.Coords()
if err != nil {
return gjf, err
}
gjf.Geometry.Coords[i][1+k] = make([][]float64, len(coords))
for j, coord := range coords {
gjf.Geometry.Coords[i][1+k][j] = make([]float64, 2)
gjf.Geometry.Coords[i][1+k][j][0] = coord.X
gjf.Geometry.Coords[i][1+k][j][1] = coord.Y
}
}
}
return gjf, nil
}