本文整理汇总了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
}