本文整理匯總了Golang中github.com/omniscale/imposm3/geom/geos.Geos.NumGeoms方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geos.NumGeoms方法的具體用法?Golang Geos.NumGeoms怎麽用?Golang Geos.NumGeoms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/omniscale/imposm3/geom/geos.Geos
的用法示例。
在下文中一共展示了Geos.NumGeoms方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: filterGeometryByType
func filterGeometryByType(g *geos.Geos, geom *geos.Geom, targetType string) []*geos.Geom {
// Filter (multi)geometry for compatible `geom_type`,
// because we can't insert points into linestring tables for example
geomType := g.Type(geom)
if geomType == targetType {
// same type is fine
return []*geos.Geom{geom}
}
if geomType == "Polygon" && targetType == "MultiPolygon" {
// multipolygon mappings also support polygons
return []*geos.Geom{geom}
}
if geomType == "MultiPolygon" && targetType == "Polygon" {
// polygon mappings should also support multipolygons
return []*geos.Geom{geom}
}
if g.NumGeoms(geom) >= 1 {
// GeometryCollection or MultiLineString? return list of geometries
var geoms []*geos.Geom
for _, part := range g.Geoms(geom) {
// only parts with same type
if g.Type(part) == targetType {
geoms = append(geoms, g.Clone(part))
}
}
g.Destroy(geom)
if len(geoms) != 0 {
return geoms
}
return []*geos.Geom{}
}
g.Destroy(geom)
return []*geos.Geom{}
}