forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
6,982 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package basic | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/terranodo/tegola" | ||
) | ||
|
||
func RehomeGeometry(geometery tegola.Geometry, ulx, uly float64) (tegola.Geometry, error) { | ||
switch geo := geometery.(type) { | ||
default: | ||
return nil, fmt.Errorf("Unknown Geometry: %+v", geometery) | ||
case tegola.Point: | ||
return &Point{int(geo.X() - ulx), int(geo.Y() - uly)}, nil | ||
case tegola.Point3: | ||
return &Point3{int(geo.X() - ulx), int(geo.Y() - uly), int(geo.Z())}, nil | ||
case tegola.MultiPoint: | ||
var pts MultiPoint | ||
for _, pt := range geo.Points() { | ||
pts = append(pts, Point{int(pt.X() - ulx), int(pt.Y() - uly)}) | ||
} | ||
return pts, nil | ||
case tegola.LineString: | ||
var line Line | ||
for _, ptGeo := range geo.Subpoints() { | ||
line = append(line, Point{int(ptGeo.X() - ulx), int(ptGeo.Y() - uly)}) | ||
} | ||
return &line, nil | ||
case tegola.MultiLine: | ||
var line MultiLine | ||
for i, lineGeo := range geo.Lines() { | ||
geoLine, err := RehomeGeometry(lineGeo, ulx, uly) | ||
if err != nil { | ||
return nil, fmt.Errorf("Got error converting line(%v) of multiline: %v", i, err) | ||
} | ||
ln, _ := geoLine.(Line) | ||
line = append(line, ln) | ||
} | ||
return line, nil | ||
case tegola.Polygon: | ||
var poly Polygon | ||
for i, line := range geo.Sublines() { | ||
geoLine, err := RehomeGeometry(line, ulx, uly) | ||
if err != nil { | ||
return nil, fmt.Errorf("Got error converting line(%v) of polygon: %v", i, err) | ||
} | ||
ln, _ := geoLine.(Line) | ||
poly = append(poly, ln) | ||
} | ||
return &poly, nil | ||
case tegola.MultiPolygon: | ||
var mpoly MultiPolygon | ||
for i, poly := range geo.Polygons() { | ||
geoPoly, err := RehomeGeometry(poly, ulx, uly) | ||
if err != nil { | ||
return nil, fmt.Errorf("Got error converting poly(%v) of multipolygon: %v", i, err) | ||
} | ||
p, _ := geoPoly.(Polygon) | ||
mpoly = append(mpoly, p) | ||
} | ||
return &mpoly, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.