Git Product home page Git Product logo

Comments (7)

j3r3m1 avatar j3r3m1 commented on August 27, 2024

What if we want functions such as "st_buffer" that needs arguments ? Should we add ['st_area', 'st_type', 'st_perimeter', ['st_buffer', 100]] or it is not designed for this purpose ?

from orbisdata.

ebocher avatar ebocher commented on August 27, 2024

it is not designed for this purpose.

from orbisdata.

SPalominos avatar SPalominos commented on August 27, 2024

In the process declaration, for the inputs and outputs, the pattern is [inputA : type, inputB, type, ...].
In the case of the example :

@Test
    void testArrayInput(){
        def process = processFactory.create(
                "title",
                [inputA : String[]],
                [outputA : String],
                { inputA ->[outputA :  inputA[0]+'the_geom) as area']}
        )
    }

from orbisdata.

j3r3m1 avatar j3r3m1 commented on August 27, 2024

That is right.
However, I still do not see whether or not a Table should be passed as input. In the case this is not the case, it means that another process should execute the sql query from an input table ?
Anyway, in the script presented here, we must at least loop on the list[] and give a "correct" name to the field that will be created in the future ?

@Test
    void testArrayInput(){
        def process = processFactory.create(
                "title",
                [inputA : String[]],
                [outputA : String],
                { inputA ->
                concat = ""
                for (fct in inputA){   
                    concat += '$fct(the_geom) as ${fct[3..-1]},'
                }
                [outputA : concat[0..-2]}
        )
    }

from orbisdata.

SPalominos avatar SPalominos commented on August 27, 2024

You can pass an ITable as a process input, but you should no call getJdbcDataSource on it (this possibility will be removed soon). If you want to do so, you should pass the JdbcDataSource (H2GIS or POSTGIS object as example).

For your example, you just have a problem of quoting, instead of concat += '$fct(the_geom) as ${fct[3..-1]},' you should write concat += "$fct(the_geom) as ${fct[3..-1]}," (double quote instead of simple quote). The ${myVar[i]} syntax works only inside double quote.
This test works well with simple array as input (like ['st_area', 'st_type', 'st_perimeter'].
To be able to use input like ['st_area', 'st_type', 'st_perimeter', ['st_buffer', 100]] you should write something like :

for (fct in inputA){
    concat += fct instanceof List ?
            "${fct[0]}(the_geom, ${fct[1]}) as ${fct[0][3..-1]}," :
            "$fct(the_geom) as ${fct[3..-1]},"
}

that will give you as output "st_area(the_geom) as area,st_type(the_geom) as type,st_perimeter(the_geom) as perimeter,st_buffer(the_geom, 100) as buffer"

from orbisdata.

SPalominos avatar SPalominos commented on August 27, 2024

@ebocher Is this issue still open ?

from orbisdata.

ebocher avatar ebocher commented on August 27, 2024

nop thx

from orbisdata.

Related Issues (20)

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.