0

我正在尝试将 a 转换.shp.stl以便将后者作为模型进行 3D 打印。

我正在遵循“ Shapefiles ”和“使用 shp2stl 将地图转换为 3D 模型”中描述的指南。

不幸的是shp2stl,这两篇文章中描述的工具对我不起作用——我正在尝试从shp2stl存储库运行一个示例,但在此过程中出现错误:

$ node index.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
/Users/eugene/oss/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.triangulateShape (/Users/eugene/oss/shp2stl/node_modules/three/three.js:32605:30)
    at THREE.ShapeGeometry.addShape (/Users/eugene/oss/shp2stl/node_modules/three/three.js:35513:32)
    at THREE.ShapeGeometry.addShapeList (/Users/eugene/oss/shp2stl/node_modules/three/three.js:35458:8)
    at THREE.ShapeGeometry (/Users/eugene/oss/shp2stl/node_modules/three/three.js:35442:7)
    at THREE.Shape.makeGeometry (/Users/eugene/oss/shp2stl/node_modules/three/three.js:32162:17)
    at /Users/eugene/oss/shp2stl/src/topojson2threejs.js:396:24
    at Array.forEach (native)
    at topojson2threeJSBottomPlanes (/Users/eugene/oss/shp2stl/src/topojson2threejs.js:392:20)
    at topojson2threejs (/Users/eugene/oss/shp2stl/src/topojson2threejs.js:76:16)
    at topojson2stl (/Users/eugene/oss/shp2stl/src/shp2stl.js:77:21)

我可能会错过什么?有没有更好的方法来获取 3D 打印文件.shp


我准备了一个 docker 镜像来帮助复制这个问题。重现我的问题的步骤:

  • 拉取图像:

    docker pull gmile/shp2stl-fiasco
    
  • 在图像中启动 bash:

    docker exec -it gmile/shp2stl-fiasco bash
    
  • 进入示例目录并尝试运行脚本:

    $ cd /shp2stl/examples/sfPopulationDensity/
    
  • 运行脚本并查看问题:

    $ node index.js
    

或者,我准备了一个 Dockerfile,可用于构建镜像以最小的努力重现问题:

FROM ubuntu:18.04

RUN apt update; \
  apt install git curl ca-certificates -y --no-install-recommends; \
  git clone https://github.com/dougmccune/shp2stl.git

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

WORKDIR /shp2stl/examples/sfPopulationDensity

# After building and entering a container, manually run the following:
#
#   nvm install v6.17.1
#   npm i
#   node index.js
4

0 回答 0