func (nw *NodeWriter) loop() { geos := geos.NewGeos() geos.SetHandleSrid(nw.srid) defer geos.Finish() for n := range nw.nodes { nw.progress.AddNodes(1) if matches := nw.tagMatcher.Match(&n.Tags); len(matches) > 0 { proj.NodeToMerc(n) if nw.expireTiles != nil { nw.expireTiles.ExpireFromNodes([]element.Node{*n}) } point, err := geom.Point(geos, *n) if err != nil { if err, ok := err.(ErrorLevel); ok { if err.Level() <= 0 { continue } } log.Println(err) continue } n.Geom, err = geom.AsGeomElement(geos, point) if err != nil { log.Println(err) continue } if nw.limiter != nil { parts, err := nw.limiter.Clip(n.Geom.Geom) if err != nil { log.Println(err) continue } if len(parts) >= 1 { nw.insertMatches(&n.OSMElem, matches) } } else { nw.insertMatches(&n.OSMElem, matches) } } } nw.wg.Done() }
func (ww *WayWriter) buildAndInsert(g *geos.Geos, w *element.Way, matches interface{}, 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 = geom.Polygon(g, way.Nodes) } else { geosgeom, err = geom.LineString(g, way.Nodes) } if err != nil { return err } way.Geom, err = geom.AsGeomElement(g, geosgeom) if err != nil { return err } if ww.limiter != nil { parts, err := ww.limiter.Clip(way.Geom.Geom) if err != nil { return err } for _, p := range parts { way := element.Way(*w) way.Geom = &element.Geometry{Geom: p, Wkb: g.AsEwkbHex(p)} if isPolygon { if err := ww.inserter.InsertPolygon(way.OSMElem, matches); err != nil { return err } } else { if err := ww.inserter.InsertLineString(way.OSMElem, matches); err != nil { return err } } } } else { if isPolygon { if err := ww.inserter.InsertPolygon(way.OSMElem, matches); err != nil { return err } } else { if err := ww.inserter.InsertLineString(way.OSMElem, matches); err != nil { return err } } } return nil }
func (nw *NodeWriter) loop() { geos := geos.NewGeos() geos.SetHandleSrid(nw.srid) defer geos.Finish() for n := range nw.nodes { nw.progress.AddNodes(1) if ok, matches := nw.inserter.ProbePoint(n.OSMElem); ok { proj.NodeToMerc(n) if nw.expireor != nil { nw.expireor.Expire(n.Long, n.Lat) } point, err := geom.Point(geos, *n) if err != nil { if errl, ok := err.(ErrorLevel); !ok || errl.Level() > 0 { log.Warn(err) } continue } n.Geom, err = geom.AsGeomElement(geos, point) if err != nil { log.Warn(err) continue } if nw.limiter != nil { parts, err := nw.limiter.Clip(n.Geom.Geom) if err != nil { log.Warn(err) continue } if len(parts) >= 1 { if err := nw.inserter.InsertPoint(n.OSMElem, matches); err != nil { log.Warn(err) continue } } } else { if err := nw.inserter.InsertPoint(n.OSMElem, matches); err != nil { log.Warn(err) continue } } } } nw.wg.Done() }
func (ww *WayWriter) buildAndInsert(geos *geos.Geos, w *element.Way, matches []mapping.Match, builder geomBuilder) { var err error // make copy to avoid interference with polygon/linestring matches way := element.Way(*w) geosgeom, err := builder(geos, way.Nodes) if err != nil { if err, ok := err.(ErrorLevel); ok { if err.Level() <= 0 { return } } log.Println(err) return } way.Geom, err = geom.AsGeomElement(geos, geosgeom) if err != nil { log.Println(err) return } if ww.limiter != nil { parts, err := ww.limiter.Clip(way.Geom.Geom) if err != nil { log.Println(err) return } for _, g := range parts { way := element.Way(*w) way.Geom = &element.Geometry{g, geos.AsEwkbHex(g)} ww.insertMatches(&way.OSMElem, matches) } } else { ww.insertMatches(&way.OSMElem, matches) } }