Permalink
Browse files

sqlite lines and multipoints are working

  • Loading branch information...
1 parent a46d060 commit b1a9c33e1ddadeadf2f124d40918ecf488bc2996 Calvin Metcalf committed May 3, 2013
Showing with 33 additions and 303 deletions.
  1. +0 −39 big.css
  2. +0 −56 big.js
  3. +0 −4 esri2open/parseGeometry.py
  4. +2 −2 esri2open/prepare.py
  5. +31 −5 esri2open/wkb.py
  6. +0 −135 index.html
  7. +0 −62 showdown.js
View
39 big.css
@@ -1,39 +0,0 @@
-body {
- font-family: 'Helvetica';
- letter-spacing:-5px;
- background:#000;
- background-size:100%;
- color:#fff;
- margin:0;
- padding:0;
- font-weight:bold;
-}
-
-h1, h2, h3, p {
- margin:0;
-}
-
-em, a {
- font-style:normal;
- color:#8dbd0c;
-}
-
-a {
- background: #34d0e7;
- color:#000;
- text-decoration:none;
-}
-
-img {
- width:100%;
-}
-
-div {
- cursor:pointer;
- cursor:hand;
- position:absolute;
- top:0;
- left:0;
-}
-
-.GreenDOT {background:#0f0;}
View
56 big.js
@@ -1,56 +0,0 @@
-window.onload = function() {
- var converter = new Showdown.converter();
- var md = document.getElementById("md");
- var html = converter.makeHtml(md.innerHTML);
- md.innerHTML = html.replace(/\<(\/)?p\>/g,'<$1div>');
- var s = document.getElementsByTagName('div'), cur = 0;
- if (!s) return;
- function go(n) {
- cur = n;
- var i = 1e3, e = s[n];
- for (var k = 0; k < s.length; k++) s[k].style.display = 'none';
- e.style.display = 'inline';
- e.style.fontSize = i + 'px';
- if (e.firstChild.nodeName === 'IMG') {
- document.body.style.backgroundImage = 'url(' + e.firstChild.src + ')';
- e.firstChild.style.display = 'none';
- } else {
- document.body.style.backgroundImage = '';
- document.body.style.backgroundColor = e.style.backgroundColor;
- }
- while (
- e.offsetWidth > window.innerWidth ||
- e.offsetHeight > window.innerHeight) {
- e.style.fontSize = (i -= 10) + 'px';
- if (i < 0) break;
- }
- e.style.marginTop = ((window.innerHeight - e.offsetHeight) / 2) + 'px';
- if (window.location.hash !== n) window.location.hash = n;
- document.title = e.textContent || e.innerText;
- }
- document.onclick = function() {
- go(++cur % (s.length));
- };
- document.onkeydown = function(e) {
- (e.which === 39) && go(Math.min(s.length - 1, ++cur));
- (e.which === 37) && go(Math.max(0, --cur));
- };
- var xStart;
- md.addEventListener("touchstart",function(e){xStart = e.changedTouches[0].pageX}, false)
- md.addEventListener("touchend",function(e){var test = e.changedTouches[0].pageX-xStart;
- (test < 0) && go(Math.min(s.length - 1, ++cur));
- (test > 0) && go(Math.max(0, --cur));
- }, false)
- function parse_hash() {
- return Math.max(Math.min(
- s.length - 1,
- parseInt(window.location.hash.substring(1), 10)), 0);
- }
- if (window.location.hash) cur = parse_hash() || cur;
- window.onhashchange = function() {
- var c = parse_hash();
- if (c !== cur) go(c);
- };
-
- go(cur);
-};
@@ -1,6 +1,5 @@
from wkt import getWKTFunc
from wkb import getWKBFunc
-from arcpy import AddMessage
def getPoint(pt):
return [pt.X,pt.Y]
@@ -192,12 +191,9 @@ def parseMultiPatch():
#this should probobly be a class
def getParseFunc(shpType, geo):
- AddMessage(shpType)
- AddMessage(geo)
if geo == "none":
return False
elif geo=="well known binary":
- AddMessage("wkb")
return getWKBFunc(shpType)
else:
if shpType == "point":
View
@@ -27,9 +27,9 @@ def prepareSqlite(out,featureClass,fileType,includeGeometry):
elif shpType == "multipoint":
gType = 4
elif shpType == "polyline":
- gType = 5
+ gType = 2
elif shpType == "polygon":
- gType = 6
+ gType = 3
fields=listFields(featureClass)
fieldNames = []
fieldNames.append("OGC_FID INTEGER PRIMARY KEY")
View
@@ -2,6 +2,32 @@
from sqlite3 import Binary
def pts(c):
return ["dd",[c.X,c.Y]]
+def pt4mp(c):
+ return ["Bidd",[1,1,c.X,c.Y]]
+def mp(coordinates):
+ partCount=coordinates.partCount
+ i=0
+ out = ["I",[0]]
+ while i<partCount:
+ pt = coordinates.getPart(i)
+ [ptrn,c]=pt4mp(pt)
+ out[0]+=ptrn
+ out[1][0]+=1
+ out[1].extend(c)
+ i+=1
+ return out
+def lineSt(coordinates):
+ partCount=coordinates.count
+ i=0
+ out = ["I",[0]]
+ while i<partCount:
+ pt = coordinates[i]
+ [ptrn,c]=pts(pt)
+ out[0]+=ptrn
+ out[1][0]+=1
+ out[1].extend(c)
+ i+=1
+ return out
def linearRing(coordinates):
partCount=coordinates.count
i=0
@@ -51,19 +77,19 @@ def makePoint(c):
return Binary(pack(*values))
def makeMultiPoint(c):
values = ["<BI",1,4]
- [ptrn,coords]=linearRing(c)
+ [ptrn,coords]=mp(c)
values[0]+=ptrn
values.extend(coords)
return Binary(pack(*values))
def makeMultiLineString(c):
- values = ["<BI",1,5]
- [ptrn,coords]=multiRing(c)
+ values = ["<BI",1,2]
+ [ptrn,coords]=lineSt(c.getPart(0))
values[0]+=ptrn
values.extend(coords)
return Binary(pack(*values))
def makeMultiPolygon(c):
- values = ["<BI",1,6]
- [ptrn,coords]=multiRing(c)
+ values = ["<BI",1,3]
+ [ptrn,coords]=linearRing(c.getPart(0))
values[0]+=ptrn
values.extend(coords)
return Binary(pack(*values))
View
@@ -1,135 +0,0 @@
-<!DOCTYPE html><html><head><title></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /><link href='big.css' rel='stylesheet' type='text/css' /><script src='showdown.js'></script><script src='big.js'></script></head><body>
-<span id="md">
-Convert ESRI to GeoJSON
-
-so you have some data in SDE
-
-and want to use it on the internet
-
-_let's just use ArcGIS online..._
-
-said nobody
-
-you want to use it in
-
-![tilemill](http://mapbox.com/tilemill/img/hero-tilemill.png)_TileMill_
-
-or
-
-![leaflet](http://farm9.staticflickr.com/8527/8680357801_712bc7e350_o_d.png)leaflet
-
-And you like having fieldnames longer then 8 charicters
-
-I'll just convert to geojson, it's similar right?
-
-![differences](http://farm9.staticflickr.com/8379/8682361435_7c54059852_o_d.png)_no_
-
-ESRI has 4 geometry types
-
-point
-
-multipoint
-
-polyline
-
-polygon
-
-GeoJSON has those
-
-but calls them Point, MultiPoint, LineString, and Polygon
-
-GeoJSON also has
-
-MultiLineString, MultiPolygon, and GeometryCollection
-
-ESRI a geometry type for the feature class and all features to have that or null
-
-GeoJSON requires it to be anything except null
-
-So I wrote an arcpy script to automate the export
-
-and then got distracted after finishing 95%
-
-But then
-
-![Michael Byrne](https://secure.gravatar.com/avatar/b57972826b35359132d2952182aa0b0e?s=1200)Michael Byrnes started his
-
-Now I MUST finish mine
-
-and/or merge our efforts
-
-anywho back to the point
-
-that 5% I had left to solve
-
-_inner rings_
-
-GeoJSON has an array with the first feature being the outer and the rest being the inner rings
-
-ESRI has a bunch of points, some of them are null
-
-you have to check the existence of eveyr point
-
-![what inner rings think of you](http://farm9.staticflickr.com/8383/8680565639_7e37a973e0_o_d.png)
-
-ESRI requires first and last point of a polygon to be the same
-
-i.e. repeat point
-
-_SO DOES GEOJSON FTW!!!1_
-
-ESRI allows polygones with a total of less then 4 points
-
-NO SANE FRAMEWORK DOES THIS!
-
-it also allows lines with only one point
-
-which means you have polygons that could be lines or points
-
-and lines that could be points
-
-and while were at it, ESRI allows multi points with only one point
-
-and makes no distinction between multi and regular for line and poly
-
-but some parts of a single multipoly could be a line
-
-and some a point
-
-and some a poly
-
-_solution_
-
-waterfall model
-
-parsePolygone either returns geo or calls parseLinestring
-
-etc with line->point
-
-fallback to next type
-
-and if a multi and mixed
-
-_GeometryCollection FTW_
-
-of course going backwards
-
-![geojson to esri](http://farm9.staticflickr.com/8391/8683474612_8b58e1c041_o_d.png)_Have Fun_
-
-_fin_
-
-[github.com/calvinmetcalf/esri2open](https://github.com/calvinmetcalf/esri2open)
-[github.com/feomike/esri2open](https://github.com/feomike/esri2open)
-[calvinmetcalf.github.io/esri2open](http://calvinmetcalf.github.io/esri2open)
-[@cwmma](https://twitter.com/CWMma)
-</span>
-<script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-40454900-1', 'github.io');
- ga('send', 'pageview');
-
-</script>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit b1a9c33

Please sign in to comment.