Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
odoe committed Nov 22, 2011
1 parent 3905dd6 commit 5029bf6
Show file tree
Hide file tree
Showing 1,519 changed files with 101,090 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
@@ -0,0 +1 @@
web: node web.js
66 changes: 66 additions & 0 deletions esritogeo.js
@@ -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;
1 change: 1 addition & 0 deletions node_modules/.bin/express

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jade

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/stylus

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/express/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5029bf6

Please sign in to comment.