Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

can now parse most esri to geojson features

  • Loading branch information...
commit 9ca4ac0a5c9473da30fe833ff9e2467306293f71 1 parent 5d15eba
@odoe authored
View
31 esritogeo.js
@@ -1,21 +1,12 @@
+var stripJSON = function(str) {
+ return str.replace(/\\n/g, "\\n")
+ .replace(/\\t/g, "\\t");
+};
+
var jsonToObject = function(stringIn) {
- console.log("Error: 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;
try {
- data = JSON.parse(stringIn);
+ data = JSON.parse(stripJSON(stringIn));
console.log("json converted to object");
} catch(err) {
data = null;
@@ -48,12 +39,16 @@ var featureToGeo = function(feature, geomType) {
// grab the rings to coordinates
var geom = feature.geometry;
- var coordinates = {};
- if (geom.rings !== "undefined") {
+
+ var coordinates;
+ if (geomType === "Polygon") {
coordinates = geom.rings;
- } else if (geom.paths !== "undefined") {
+ } else if (geomType === "LineString") {
coordinates = geom.paths;
+ } else if (geomType === "Point") {
+ coordinates = [geom.x, geom.y];
}
+
geometry.coordinates = coordinates;
// convert attributes to properties
View
3  public/stylesheets/partials/typography.styl
@@ -1,6 +1,7 @@
h1
color #666
- font 4em 'ChunkFiveRegular'
+ font-family 'Ultra', serif
+ font-size: 2.0em
line-height 0.9em
margin-bottom 0.9em
View
269 public/stylesheets/style.css
@@ -0,0 +1,269 @@
+/* Reset
+Based on http://meyerweb.com/eric/thoughts/2008/01/15/resetting-again/
+Removed elements not supported in HTML5
+-----------------------------------------------------------------------------*/
+html,
+body,
+div,
+span,
+object,
+iframe,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+p,
+blockquote,
+pre,
+a,
+abbr,
+address,
+cite,
+code,
+del,
+dfn,
+em,
+img,
+ins,
+kbd,
+q,
+samp,
+small,
+strike,
+strong,
+sub,
+sup,
+var,
+b,
+i,
+dl,
+dt,
+dd,
+ol,
+ul,
+li,
+fieldset,
+form,
+label,
+legend,
+table,
+caption,
+tbody,
+tfoot,
+thead,
+tr,
+th,
+td {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-size: 100%;
+ vertical-align: baseline;
+}
+/*
+Trigger the new block level elements in to the correct content flow
+-----------------------------------------------------------------------------*/
+article,
+aside,
+dialog,
+figure,
+footer,
+header,
+hgroup,
+menu,
+nav,
+section {
+ display: block;
+}
+/* Set up document
+-----------------------------------------------------------------------------*/
+body {
+ font: 62.5%/1.5 Helvetica, Arial, "Lucida Grande", "Lucida Sans", Tahoma, Verdana, sans-serif;
+ text-align: center;
+ background: #000;
+}
+#wrapper {
+ width: 920px;
+ text-align: left;
+ margin-left: auto;
+ margin-right: auto;
+ background: #fff;
+ padding: 20px;
+ -webkit-border-bottom-left-radius: 15px;
+ -moz-border-bottom-left-radius: 15px;
+ -o-border-bottom-left-radius: 15px;
+ border-bottom-left-radius: 15px;
+ -webkit-border-bottom-right-radius: 15px;
+ -moz-border-bottom-right-radius: 15px;
+ -o-border-bottom-right-radius: 15px;
+ border-bottom-right-radius: 15px;
+}
+/* Typography
+-----------------------------------------------------------------------------*/
+h1 {
+ color: #666;
+ font-family: 'Ultra', serif;
+ font-size: 2em;
+ line-height: 0.9em;
+ margin-bottom: 0.9em;
+}
+h2 {
+ font-size: 1.8em;
+ line-height: 1em;
+ margin-bottom: 1em;
+}
+h3 {
+ font-size: 1.6em;
+ line-height: 1.13em;
+ margin-bottom: 1.13em;
+}
+h4 {
+ font-size: 1.4em;
+ line-height: 1.29em;
+ margin-bottom: 1.29em;
+}
+h5 {
+ font-size: 1.3em;
+ line-height: 1.38em;
+ margin-bottom: 1.38em;
+}
+h6 {
+ font-size: 1.2em;
+ line-height: 1.5em;
+ margin-bottom: 1.5em;
+}
+p,
+q,
+cite,
+address,
+ul,
+ol,
+dl {
+ font-size: 1.2em;
+ line-height: 1.5em;
+ margin-bottom: 1.5em;
+}
+li,
+dd,
+dt {
+ font-size: 1em;
+}
+a {
+ text-decoration: underline;
+ color: #33c;
+ outline: none;
+}
+a:hover {
+ text-decoration: none;
+}
+code,
+samp,
+dfn,
+kbd,
+var,
+acronym,
+ins,
+del,
+abbr {
+ speak: spell-out;
+}
+acronym {
+ speak: normal;
+}
+/* CSS Tables
+-----------------------------------------------------------------------------*/
+.css-table {
+ width: 100%;
+ display: table;
+}
+.css-table .two-column {
+ display: table-row;
+}
+.css-table .two-column .cell {
+ display: table-cell;
+ vertical-align: top;
+ width: 50%;
+}
+.css-table .two-column .cell * {
+ width: 90%;
+}
+.css-table .three-column {
+ display: table-row;
+}
+.css-table .three-column .cell {
+ display: table-cell;
+ width: 33.33333%;
+}
+.css-table .three-column .cell * {
+ width: 90%;
+}
+.css-table .four-column {
+ display: table-row;
+}
+.css-table .four-column .cell {
+ display: table-cell;
+ width: 25%;
+}
+/* Header
+-----------------------------------------------------------------------------*/
+header {
+ background: #f00060;
+}
+header nav {
+ width: 960px;
+ text-align: right;
+ margin-left: auto;
+ margin-right: auto;
+}
+header nav ul {
+ list-style: none;
+ padding: 10px;
+ margin-bottom: 0;
+}
+header nav ul li {
+ display: inline;
+ margin-left: 1%;
+}
+header nav ul li a {
+ background: #fc9200;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ -o-border-radius: 15px;
+ border-radius: 15px;
+ display: inline-block;
+ padding: 5px 15px 6px;
+ color: #fff;
+ text-decoration: none;
+ position: relative;
+ cursor: pointer;
+}
+header nav ul li a:hover {
+ background-color: #db0d5f;
+}
+/* Footer
+-----------------------------------------------------------------------------*/
+footer {
+ color: #666;
+ border-top: 1px solid #ccc;
+ padding-top: 1.5em;
+}
+footer ul {
+ list-style: none;
+}
+/* main container (my additions)
+-----------------------------------------------------------------------------*/
+#wrapper {
+ height: 75%;
+}
+/* Textarea (my additions)
+-----------------------------------------------------------------------------*/
+form {
+ height: 100%;
+}
+textarea {
+ width: 100%;
+ height: 150px;
+}
View
5 public/stylesheets/style.styl
@@ -112,5 +112,10 @@ footer
ul
list-style none
+/* main container (my additions)
+-----------------------------------------------------------------------------*/
/* Textarea (my additions)
-----------------------------------------------------------------------------*/
+textarea
+ width 100%
+ height 150px
View
6 views/index.jade
@@ -5,7 +5,7 @@ form( method='post', action='/' )
label EsriJSON
textarea(name='inJson', value=jsonIn)=jsonIn
div
- label GeoJSON
- textarea= jsonOut
+ input(type='submit', value='convert')
div
- input(type='submit', value='go')
+ label GeoJSON
+ textarea= jsonOut
View
1  views/layout.jade
@@ -2,6 +2,7 @@
html
head
title= title
+ link(rel='stylesheet', href='http://fonts.googleapis.com/css?family=Ultra')
link(rel='stylesheet', href='/stylesheets/style.css')
body
header
View
22 web.js
@@ -8,11 +8,29 @@ app.configure(function(){
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
- app.use(require('stylus').middleware({ src: __dirname + 'public' }));
+ /*
+ app.use(require('stylus').middleware({
+ debug: true,
+ src: __dirname + '/views',
+ dest: __dirname + '/public',
+ compile: compileMethod
+ }));
+ */
+ app.use(require('stylus').middleware({
+ debug: true,
+ src: __dirname + '/public',
+ dest: __dirname + '/public',
+ compile: compileMethod
+ }));
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
+var compileMethod = function (str) {
+ return require('stylus')(str)
+ .set('compress', true);
+};
+
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
@@ -29,7 +47,7 @@ var jsonOutput = "this will be GeoJSON";
app.get('/', function(req, res){
console.log('start of app');
res.render('index', {
- title: 'EsriJSON to GeoJSON (experimental): Only works on Polygons for now',
+ title: 'EsriJSON to GeoJSON (experimental)',
locals: { jsonIn: jsonInput, jsonOut: jsonOutput }
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.