Ejemplo n.º 1
0
// MVT needs relative point instead of absolute
func (f *Feature) relativeGeometry() (geom *Geometry) {
	//TODO if RelCur -> skip translation
	geom = newGeometry(f.gtype, f.shapes...)
	cur := Point{X: 0, Y: 0}
	if f.id != nil {
		util.Debug("Feature Geometry id: %d", *f.id)
	} else {
		util.Debug("Feature Geometry <nil>")
	}
	for k, v := range f.props {
		util.Debug("\t%v: %v", k, v)
	}
	for i, shape := range f.shapes {
		if f.gtype == vt.Tile_POLYGON {
			shape.points = shape.points[:len(shape.points)-1]
		}
		shape.geomType = f.gtype
		util.Debug("\tShape %d", i)
		for i, point := range shape.points {
			diff := point.Subtract(cur)
			shape.points[i] = diff
			cur = point
			util.Debug("\t\t%v", cur)
		}
		shape.curType = RelCur
	}
	return
}
Ejemplo n.º 2
0
Archivo: csv.go Proyecto: buckhx/diglet
func readHeaders(reader *csv.Reader, filter mapset.Set) (headers map[string]int) {
	line, err := reader.Read()
	util.Warn(err, "reading headers")
	headers = make(map[string]int, len(line))
	for i, k := range line {
		//if _, ok := c.fields[k]; !ok {
		k = util.Slugged(k, "_")
		if filter == nil || filter.Contains(k) {
			headers[k] = i
		}
		//}
	}
	util.Debug("Headers %v", headers)
	return
}