本文整理匯總了Golang中github.com/omniscale/imposm3/geom/geos.Geos.Intersection方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geos.Intersection方法的具體用法?Golang Geos.Intersection怎麽用?Golang Geos.Intersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/omniscale/imposm3/geom/geos.Geos
的用法示例。
在下文中一共展示了Geos.Intersection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: splitPolygonAtGrid
func splitPolygonAtGrid(g *geos.Geos, geom *geos.Geom, gridWidth, currentGridWidth float64) ([]*geos.Geom, error) {
var result []*geos.Geom
geomBounds := geom.Bounds()
if geomBounds == geos.NilBounds {
return nil, errors.New("couldn't create bounds for geom")
}
for _, bounds := range tileBounds(geom.Bounds(), currentGridWidth) {
clipGeom := g.BoundsPolygon(bounds)
if clipGeom == nil {
return nil, errors.New("couldn't create bounds polygon")
}
part := g.Intersection(geom, clipGeom)
g.Destroy(clipGeom)
if part == nil {
return nil, errors.New("couldn't create intersection")
}
if !g.IsEmpty(part) && strings.HasSuffix(g.Type(part), "Polygon") {
if gridWidth >= currentGridWidth {
result = append(result, part)
} else {
moreParts, err := splitPolygonAtGrid(g, part, gridWidth, currentGridWidth/2.0)
g.Destroy(part)
if err != nil {
return nil, err
}
result = append(result, moreParts...)
}
}
}
return result, nil
}