Coder Social home page Coder Social logo

makevalid's Introduction

makevalid

Simple tool to "makevalid" files containing WKT geometries.

usage

makevalid is a simple command-line tool which reads an input file containing two fields: an ID and a WKT geometry. The fields should be pipe-delimited.

./makevalid --help  # print help info
Usage: makevalid [OPTIONS] INPUT_FILE

Read INPUT_FILE and load WKT geometries, and fix any which are invalid.
INPUT_FILE must be a file with two fields separated by a pipe [|]. The first field should be an ID, and the second should be the WKT geometry to be made valid. The file should have no header.
By default, output is written to stdout and only changed geometries are written.

Options:
	-o	specify output file.
	-a	output all geometries, not just those which have been fixed.
	-s	skip the first line of the file (a header).

makevalid will print to stdout by default. You can use the -o FILENAME option to specify an output file to write to, instead. By default, only geometries which are altered (made valid) will be written. To write them all instead, use -a. If your file has a header, you can use -s to skip the first line. The header will not be written to the output file.

makevalid will write the number of geometries processed and the number fixed to stderr when the program is complete. To silence it, use -q.

build and install

Requires GEOS >= 3.8 & cmake >= 3.13. The standard system locations will be searched for GEOS. Please note that the build will not try all possible GEOS installations but just the first found by cmake. If that version is not >=3.8, you will have to specify the path to your installation explicitly.

git clone [email protected]:tomplex/makevalid.git
cd makevalid

# optionally specify location of GEOS library.
# /usr/ and /usr/local will be searched by default.
cmake -DGEOS_DIR=/usr/local/geos/3.8.1/ . && make

This will create an executable called makevalid in your local directory.

If you explictly specify a directory, it should be the root install directory for geos, such that the directory contains the GEOS bin, include, and lib directories, like so:

❯ ll /usr/local/geos/3.8.1/
total 0
drwxr-xr-x   5 root  wheel  160 Apr  8 17:56 .
drwxr-xr-x   4 root  wheel  128 Apr 21 00:27 ..
drwxr-xr-x   3 root  wheel   96 Apr  8 17:56 bin
drwxr-xr-x   5 root  wheel  160 Apr  8 17:56 include
drwxr-xr-x  10 root  wheel  320 Apr  8 17:56 lib

This directory is equivalent to the --prefix used when installing GEOS from source.

If you are on Linux/MacOS, you can install GEOS from source like so, assuming wget is installed. You should be able to use curl interchangeably.

pushd /tmp
wget http://download.osgeo.org/geos/geos-3.8.1.tar.bz2

tar -xf geos-3.8.1.tar.bz2
pushd geos-3.8.1/
./configure --prefix=/usr/local/geos/3.8.1
make -j 4 
sudo make install
popd; popd

This will install GEOS from source in the directory /usr/local/geos/3.8.1. You can then run the install commands for makevalid above, verbatim.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.