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
1,519 changed files
with
101,090 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node web.js |
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,66 @@ | ||
var jsonToObject = function(stringIn) { | ||
console.log("parse with JSON.parse()"); | ||
|
||
/* | ||
var data = JSON.parse(stringIn, function(key, value) { | ||
var type; | ||
if (value && typeof value === 'object') { | ||
type = value.type; | ||
if (typeof type === 'string' && typeof window[type] === 'function') { | ||
return new (window[type])(value); | ||
} | ||
} | ||
return value; | ||
}); | ||
*/ | ||
|
||
var data = JSON.parse(stringIn); | ||
console.log("json converted to object"); | ||
return data; | ||
}; | ||
|
||
var parseGeometryType = function(type) { | ||
if (type === "esriGeometryPolygon") { | ||
return "Polygon"; | ||
} | ||
return "none"; | ||
}; | ||
|
||
var deserialize = function(js, callback) { | ||
console.log("begin parsing json"); | ||
var geoJS = {}; | ||
var o = jsonToObject(js); | ||
var geomType; | ||
geomType = parseGeometryType(o.geometryType); | ||
|
||
// prepare the main parts of the GeoJSON | ||
var geometry = {}; | ||
geometry.type = geomType; | ||
|
||
// grab the rings to coordinates | ||
var coordinates = o.features[0].geometry.rings; | ||
geometry.coordinates = coordinates; | ||
|
||
// convert attributes to properties | ||
var properties = {}; | ||
var attr = o.features[0].attributes; | ||
for (var field in attr) { | ||
properties[field] = attr[field]; | ||
} | ||
|
||
geoJS.geometry = geometry; | ||
geoJS.properties = properties; | ||
|
||
var result = JSON.stringify(geoJS, function(key, value) { | ||
if (typeof value === 'number' && !isFinite(value)) { | ||
return String(value); | ||
} | ||
return value; | ||
}); | ||
|
||
console.log("json parsed, return it"); | ||
|
||
callback(null, result); | ||
}; | ||
|
||
exports.deserialize = deserialize; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.