本文整理汇总了Golang中github.com/whosonfirst/go-whosonfirst-geojson.WOFFeature类的典型用法代码示例。如果您正苦于以下问题:Golang WOFFeature类的具体用法?Golang WOFFeature怎么用?Golang WOFFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WOFFeature类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: LoadPolygonsForFeature
func (p WOFPointInPolygon) LoadPolygonsForFeature(feature *geojson.WOFFeature) ([]*geojson.WOFPolygon, error) {
id := feature.Id()
polygons := feature.GeomToPolygons()
var points int
for _, pl := range polygons {
points += pl.CountPoints()
}
p.Logger.Debug("%d has %d points", id, points)
if points >= p.CacheTrigger {
p.Logger.Debug("caching %d because it has E_EXCESSIVE_POINTS (%d)", id, points)
var c metrics.Counter
c = *p.Metrics.CountCacheSet
evicted := p.Cache.Add(id, polygons)
if evicted == true {
cache_size := p.CacheSize
cache_set := c.Count()
p.Logger.Warning("starting to push thing out of the cache %d sets on a cache size of %d", cache_set, cache_size)
}
go c.Inc(1)
}
return polygons, nil
}
开发者ID:missinglink,项目名称:go-whosonfirst-pip,代码行数:35,代码来源:pip.go
示例2: LoadPolygonsForFeature
func (idx *WOFIndex) LoadPolygonsForFeature(feature *geojson.WOFFeature) ([]*geojson.WOFPolygon, error) {
id := feature.Id()
polygons := feature.GeomToPolygons()
var points int
for _, pl := range polygons {
points += pl.CountPoints()
}
idx.Logger.Debug("%d has %d points", id, points)
if points >= idx.CacheTrigger {
idx.Logger.Debug("caching %d because it has E_EXCESSIVE_POINTS (%d)", id, points)
evicted := idx.Cache.Add(id, polygons)
if evicted == true {
idx.Logger.Warning("starting to push thing out of the cache")
}
}
return polygons, nil
}
开发者ID:whosonfirst,项目名称:go-whosonfirst-rtree,代码行数:27,代码来源:rtree.go
示例3: IndexGeoJSONFeature
func (p WOFPointInPolygon) IndexGeoJSONFeature(feature *geojson.WOFFeature) error {
spatial, spatial_err := feature.EnSpatialize()
if spatial_err != nil {
body := feature.Body()
geom_type, ok := body.Path("geometry.type").Data().(string)
if ok && geom_type == "Point" {
p.Logger.Warning("feature is a Point type so I am ignoring it...")
return nil
}
p.Logger.Error("failed to enspatialize feature, because %s", spatial_err)
return spatial_err
}
return p.IndexSpatialFeature(spatial)
}
开发者ID:missinglink,项目名称:go-whosonfirst-pip,代码行数:20,代码来源:pip.go
示例4: IndexGeoJSONFeature
func (idx *WOFIndex) IndexGeoJSONFeature(feature *geojson.WOFFeature) error {
spatial, spatial_err := feature.EnSpatializeGeom()
if spatial_err != nil {
idx.Logger.Error("failed to enspatialize feature, because %s", spatial_err)
return spatial_err
}
for _, sf := range spatial {
err := idx.IndexSpatialFeature(sf)
if err != nil {
return err
}
}
return nil
}
开发者ID:whosonfirst,项目名称:go-whosonfirst-rtree,代码行数:20,代码来源:rtree.go
示例5: Breaches
func (idx *Index) Breaches(feature *geojson.WOFFeature) ([]*geojson.WOFSpatial, error) {
clipping, err := feature.EnSpatialize()
if err != nil {
return nil, err
}
breaches := make([]*geojson.WOFSpatial, 0)
bounds := clipping.Bounds()
results := idx.GetIntersectsByRect(bounds)
// idx.Logger.Info("possible results for %v : %d", bounds, len(results))
if len(results) > 0 {
t1 := time.Now()
clipping_polys := feature.GeomToPolygons()
idx.Logger.Debug("compare %d polys from clipping against %d possible subjects", len(clipping_polys), len(results))
// See what's going on here? We are *not* relying on the standard Inflate method
// but rather bucketing all the WOFSpatials by their WOF ID (this is because the
// (WOF) rtree package indexes the bounding boxes of individual polygons on the
// geom rather than the bounding box of the set of polygons) which we we will
// loop over below (20151130/thisisaaronland)
inflated := make(map[int][]*geojson.WOFSpatial)
for _, r := range results {
wof := r.(*geojson.WOFSpatial)
wofid := wof.Id
_, ok := inflated[wofid]
possible := make([]*geojson.WOFSpatial, 0)
if ok {
possible = inflated[wofid]
}
possible = append(possible, wof)
inflated[wofid] = possible
}
for wofid, possible := range inflated {
if wofid == feature.WOFId() {
idx.Logger.Debug("%d can not breach itself, skipping", wofid)
continue
}
// Despite the notes about goroutines and yak-shaving below this is probably
// a pretty good place to do things concurrently (21051130/thisisaaronland)
subject_polys, err := idx.LoadPolygons(possible[0])
if err != nil {
idx.Logger.Warning("Unable to load polygons for ID %d, because %v", wofid, err)
continue
}
idx.Logger.Debug("testing %d with %d possible candidates", wofid, len(possible))
// Note to self: it turns out that goroutine-ing these operations is yak-shaving
// and often slower (20151130/thisisaaronland)
for i, subject := range possible {
idx.Logger.Debug("testing %d (offset %d) with candidate %d", wofid, subject.Offset, i)
test_polys := make([]*geojson.WOFPolygon, 0)
if subject.Offset == -1 {
test_polys = subject_polys
} else {
test_polys = append(test_polys, subject_polys[subject.Offset])
}
intersects, err := idx.Intersects(clipping_polys, test_polys)
if err != nil {
idx.Logger.Error("Failed to determine intersection, because %v", err)
continue
}
if intersects {
breaches = append(breaches, subject)
idx.Logger.Debug("determined that %d breaches after %d/%d iterations", wofid, i, len(possible))
break
}
}
}
t2 := time.Since(t1)
idx.Logger.Debug("time to test %d possible results: %v", len(results), t2)
}
//.........这里部分代码省略.........
开发者ID:whosonfirst,项目名称:go-whosonfirst-breaches,代码行数:101,代码来源:breaches.go
注:本文中的github.com/whosonfirst/go-whosonfirst-geojson.WOFFeature类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论