OK, I have progress on Ubuntu. The complicated JSON error is caused simply because the input file is not found. The code doesn't check that the file exists before attempting to convert it, so it crashes! This fits with Neil's first post 'specifically, the example code has no file path in it.'
The path is needed. From where I installed the package and the example files, the path is:
var file = '3dmaps-master/sfPopulation/SanFranciscoPopulation.shp';
Also, on Ubuntu at least:
- npm has to be run with administrator privilges
- I had to npm install all the packages mentioned in the blog plus fs. They were fs shapefile topojson three deepcopy point-in-polygon & ogr2ogr
The output is promising until the example script (I called it eq.js) throws another exception and fails:
node eq.js
bounds: 5979385.645656869 2085840.5000395626 6024741.001443654 2131293.9999859035 (cartesian)
pre-quantization: 0.00045355356240339045 0.0004545350040087592
topology: 1698 arcs, 37009 points
topojson done
simplification: effective minimum area 0.00000299
simplification: retained 29608 / 37009 points (80%)
making top planes
making side planes
making bottom planes
/home/dave/js/node_modules/shp2stl/node_modules/three/three.js:32605
for ( i = 0, il = triangles.length; i < il; i ++ ) {
^
TypeError: Cannot read property 'length' of null
at Object.THREE.Shape.Utils.triangulateShape (/home/dave/js/node_modules/shp2stl/node_modules/three/three.js:32605:30)
Might be a data problem; I'll look at it tomorrow. There is a debugger but I haven't sussed out how to use it.
Dave