Last active
February 2, 2016 01:43
-
-
Save n1n9-jp/4fc4121b0a977680e065 to your computer and use it in GitHub Desktop.
WKT形式をGeoJSON形式に変換する ref: http://qiita.com/yuichy/items/14f2cb7d4ed113eca727
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
<script src="terraformer.min.js"></script> | |
<script src="terraformer-wkt-parser.min.js"></script> |
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
var geoJSONSingle = Terraformer.WKT.parse( wktSingle ); |
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
MULTIPOINT ((10 40), (40 30), (20 20), (30 10)) |
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
{"type":"MultiPoint","coordinates":[[10,40],[40,30],[20,20],[30,10]],"bbox":[10,10,40,40]} |
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
//wktObj...変換前のWKTデータ、geoJSONObj...変換後のGeoJsonデータ | |
var _geoArray = new Array(); | |
for (var i=0; i<wktObj.length; i++) { | |
var _o = new Object(); | |
_o["type"] = "Feature"; | |
_o["geometry"] = Terraformer.WKT.parse( wktObj[i] ); | |
_o["properties"] = {"country_id": "some_id", | |
"count": "some_count"}; | |
_geoArray[i] = _a; | |
}; | |
var geoJSONObj = { | |
"type": "FeatureCollection" | |
}; | |
geoJSONObj["features"] = _geoArray; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment