jericks / geoc

A geospatial command line application.
http://jericks.github.io/geoc/index.html
MIT License
6 stars 0 forks source link

Multiple commands? #4

Closed dr-jts closed 4 years ago

dr-jts commented 4 years ago

Hey Jared. Have you thought about allowing a pipe of multiple commands to be executed? That avoids the marshalling cost between commands. It also allows sharing parameters.

jericks commented 4 years ago

I have been thinking about this for quite a while. While you can pipe multiple geoc commands using unix pipes that incurs the performance penalty of starting java multiple times. I have looked into GraalVM and compiling geoc using nativeimage, but I haven't been able to get that to work (yet). So some internal pipe command would be great.

dr-jts commented 4 years ago

Great.. I have been thinking about adding this to JtsOp. Perhaps using a syntax like:

op args... | op args.. | ...

One tricky thing is handling 2-arg functions. For those I might add the concept of named subpipes, which can then be used as input to other pipelines. Obv. getting a bit complex, but if that's what's needed...

JtsOp also has the concept of "spreading" an operation over each element of an input collection, which is handy.

jericks commented 4 years ago

I added a pipe command to my geometrycommands project:

https://github.com/jericks/geometrycommands/commit/cb7a25b18663d075f50dd4f3f2ffb67fe7977b8c

it looks like this:

geom pipe -c "buffer -g 'POINT(1 1)' -d 10 | centroid"

I am also working on native c++ / geos version of geometrycommands at https://github.com/jericks/geos-cli

dr-jts commented 4 years ago

Nice! Exactly what I am thinking of doing for JtsOp. Better get on that!

The GEOS utility should be VERY useful, since there isn't an easy way to run GEOS operations (unlike JTS, which has the TestBuilder). We have been thinking of providing something right in the GEOS project, so that it is easily available during development. Hmmm... would you be interested in contributing it at some point?

jericks commented 4 years ago

Yes, I would be very happy to contribute it to the GEOS project.

jericks commented 4 years ago

Finally added the pipe command to this project:

geoc pipe -c "vector randompoints -n 10 -g '1,1,10,10' | vector buffer -d 10"

Should be a nice performance improvement since it only invokes the JVM once.