Closed MathiasVersichele closed 3 years ago
I had no problem loading your network using python 2 and 3 running in docker.
So I image it is a problem with your environment and configuration.
There's a docker file here you can use to test things out with python 2: https://github.com/cyang-kth/fmm/tree/master/docker
If you want to test things out with python 3 you can use this docker file here I threw together:
# Pull alpine base image
FROM alpine:3.12.0
# Install required FMM dependencies
RUN apk update && \
apk add --no-cache \
alpine-sdk \
g++ \
gdal \
gdal-dev \
cmake \
boost-dev \
boost-serialization \
libbz2 \
expat-dev \
swig \
python3-dev
# Define a user and a wokring directory
ARG user=fmm
ARG home=/usr/src/$user
# Create the new working directory
RUN mkdir -p $home
# Set the current working directory.
WORKDIR $home
# Create a symbolic link for aliasing python3 as python
RUN ln -s /usr/bin/python3 /usr/bin/python && \
ln -s /usr/bin/pip3 /usr/bin/pip
# Clone the FMM github repository
RUN git clone https://github.com/cyang-kth/fmm.git && \
cd fmm && \
mkdir build && \
cd build && \
cmake .. -DPYTHON_LIBRARY=/usr/lib/libpython3.8.so -DPYTHON_INCLUDE_DIR=/usr/include/python3.8 && \
make -j4 && \
make install && \
make clean
Then just build and run the image similar to how it was done with python 2 (since alpine linux is used as the base image you will probably have to run /bin/sh
instead of /bin/bash
).
I just managed to load the file. To generate the shapefile I used st_snaptogrid(geom, 1) to round the geoms to 1m precision. When I don't simplify the geoms anymore, it loads fine. I guess the simplification makes some geoms (very short lines) collapse to NULL geometries. Weird that the attached file loads without issues for you though...
Hmm, I see. I can't really give you any answers to that.
I only had a brief look at the library just now and looked through the issues :p
With both of the docker images I built and ran I got the trace:
[2021-02-02 18:17:56.585] [info] [network.cpp:72] Read network from file geouniq_nl_car_small.shp
[2021-02-02 18:17:56.672] [info] [network.cpp:170] Number of edges 4738 nodes 4021
[2021-02-02 18:17:56.672] [info] [network.cpp:171] Field index: id 0 source 1 target 2
[2021-02-02 18:17:56.675] [info] [network.cpp:174] Read network done
... after running the two commands you pasted in the original post.
Ok, thanks for looking into it anyway! So, the issue for me is solved making sure no geometries collapse unto themselves by simplifying them.
I just installed fmm on Mac (took some time making it work on python3), but I think the install went fine in the end. Running fmm_test.py finishes without any errors. However, when I try to read in a shapefile I made on my own, it throws a "Segmentation fault: 11":
I think my shapefile has the correct structure:
The geoms are in a projected coordinate system, but that shouldn't be the problem right ? I tried just reading in a smaller part of the network, but it still fails. I'm attaching the network I'm trying to load. small_network.zip
Any help would be much appreciated !