本文整理匯總了Golang中github.com/omniscale/imposm3/geom/geos.Geos.AsEwkbHex方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geos.AsEwkbHex方法的具體用法?Golang Geos.AsEwkbHex怎麽用?Golang Geos.AsEwkbHex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/omniscale/imposm3/geom/geos.Geos
的用法示例。
在下文中一共展示了Geos.AsEwkbHex方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AsGeomElement
func AsGeomElement(g *geos.Geos, geom *geos.Geom) (Geometry, error) {
wkb := g.AsEwkbHex(geom)
if wkb == nil {
return Geometry{}, errors.New("could not create wkb")
}
return Geometry{
Wkb: wkb,
Geom: geom,
}, nil
}
示例2: buildAndInsert
func (ww *WayWriter) buildAndInsert(g *geos.Geos, w *element.Way, matches []mapping.Match, isPolygon bool) error {
var err error
var geosgeom *geos.Geom
// make copy to avoid interference with polygon/linestring matches
way := element.Way(*w)
if isPolygon {
geosgeom, err = geomp.Polygon(g, way.Nodes)
if err == nil {
geosgeom, err = g.MakeValid(geosgeom)
}
} else {
geosgeom, err = geomp.LineString(g, way.Nodes)
}
if err != nil {
return err
}
geom, err := geomp.AsGeomElement(g, geosgeom)
if err != nil {
return err
}
if ww.limiter != nil {
parts, err := ww.limiter.Clip(geom.Geom)
if err != nil {
return err
}
for _, p := range parts {
way := element.Way(*w)
geom = geomp.Geometry{Geom: p, Wkb: g.AsEwkbHex(p)}
if isPolygon {
if err := ww.inserter.InsertPolygon(way.OSMElem, geom, matches); err != nil {
return err
}
} else {
if err := ww.inserter.InsertLineString(way.OSMElem, geom, matches); err != nil {
return err
}
}
}
} else {
if isPolygon {
if err := ww.inserter.InsertPolygon(way.OSMElem, geom, matches); err != nil {
return err
}
} else {
if err := ww.inserter.InsertLineString(way.OSMElem, geom, matches); err != nil {
return err
}
}
}
return nil
}
示例3: handleRelationMembers
func handleRelationMembers(rw *RelationWriter, r *element.Relation, geos *geosp.Geos) bool {
relMemberMatches := rw.relationMemberMatcher.MatchRelation(r)
if relMemberMatches == nil {
return false
}
for i, m := range r.Members {
if m.Type == element.RELATION {
mrel, err := rw.osmCache.Relations.GetRelation(m.Id)
if err != nil {
if err != cache.NotFound {
log.Warn(err)
}
return false
}
r.Members[i].Elem = &mrel.OSMElem
} else if m.Type == element.NODE {
nd, err := rw.osmCache.Nodes.GetNode(m.Id)
if err != nil {
if err == cache.NotFound {
nd, err = rw.osmCache.Coords.GetCoord(m.Id)
if err != nil {
if err != cache.NotFound {
log.Warn(err)
}
return false
}
} else {
log.Warn(err)
return false
}
}
rw.NodeToSrid(nd)
r.Members[i].Node = nd
r.Members[i].Elem = &nd.OSMElem
}
}
for _, m := range r.Members {
var g *geosp.Geom
var err error
if m.Node != nil {
g, err = geomp.Point(geos, *m.Node)
} else if m.Way != nil {
g, err = geomp.LineString(geos, m.Way.Nodes)
}
if err != nil {
log.Warn(err)
return false
}
var gelem geomp.Geometry
if g == nil {
g = geos.FromWkt("POLYGON EMPTY")
gelem = geomp.Geometry{Geom: g, Wkb: geos.AsEwkbHex(g)}
} else {
gelem, err = geomp.AsGeomElement(geos, g)
if err != nil {
log.Warn(err)
return false
}
}
rel := element.Relation(*r)
rel.Id = rw.relId(r.Id)
rw.inserter.InsertRelationMember(rel, m, gelem, relMemberMatches)
}
return true
}
示例4: handleMultiPolygon
func handleMultiPolygon(rw *RelationWriter, r *element.Relation, geos *geosp.Geos) bool {
// prepare relation first (build rings and compute actual
// relation tags)
prepedRel, err := geomp.PrepareRelation(r, rw.srid, rw.maxGap)
if err != nil {
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
log.Warn(err)
}
return false
}
// check for matches befor building the geometry
matches := rw.polygonMatcher.MatchRelation(r)
if matches == nil {
return false
}
// build the multipolygon
geom, err := prepedRel.Build()
if geom.Geom != nil {
defer geos.Destroy(geom.Geom)
}
if err != nil {
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
log.Warn(err)
}
return false
}
if rw.limiter != nil {
start := time.Now()
parts, err := rw.limiter.Clip(geom.Geom)
if err != nil {
log.Warn(err)
return false
}
if duration := time.Now().Sub(start); duration > time.Minute {
log.Warnf("clipping relation %d to -limitto took %s", r.Id, duration)
}
for _, g := range parts {
rel := element.Relation(*r)
rel.Id = rw.relId(r.Id)
geom = geomp.Geometry{Geom: g, Wkb: geos.AsEwkbHex(g)}
err := rw.inserter.InsertPolygon(rel.OSMElem, geom, matches)
if err != nil {
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
log.Warn(err)
}
continue
}
}
} else {
rel := element.Relation(*r)
rel.Id = rw.relId(r.Id)
err := rw.inserter.InsertPolygon(rel.OSMElem, geom, matches)
if err != nil {
if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 {
log.Warn(err)
}
return false
}
}
for _, m := range mapping.SelectRelationPolygons(rw.polygonMatcher, r) {
err = rw.osmCache.InsertedWays.PutWay(m.Way)
if err != nil {
log.Warn(err)
}
}
return true
}