(no subject)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

hanae bourziza

Hi,

I am having some issues writing a sql query that uses the Postgis function ST_Contains(geometry geomA, geometry geomB) 

FeatureQuery query = store.createFeatureQuery();
query.setFilter( manager.createExpresion("ST_Contains(geomA, geomB)") );
I am getting this error org.medfoster.sqljep.parseexception, could anyone help?
thanks


_______________________________________________
gvSIG-desktop-devel mailing list
http://joinup.ec.europa.eu/mailman/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Joaquin Jose del Cerro Murciano


2016-10-19 10:51 GMT+02:00 hanae bourziza <[hidden email]>:

Hi,

I am having some issues writing a sql query that uses the Postgis function ST_Contains(geometry geomA, geometry geomB) 

FeatureQuery query = store.createFeatureQuery();
query.setFilter( manager.createExpresion("ST_Contains(geomA, geomB)") );
I am getting this error org.medfoster.sqljep.parseexception, could anyone help?


Hello Hanae,
To use spatial filters in querys, use a
class that extends Evaluator. The method setFilter in
FeatureQuery is something like:

void setFilter (Evaluator filter);

The createExpresion method of DataManager
creates a specific Evaluator (SQLJEPEvaluator) that is capable of
filter by alphanumeric conditions, and although it has spatial support
for some functions. Currently the spatial functions
supported are:

- GeomFromText
- Intersects
- Overlaps
- Boundary

However I would not advise using this evaluator for
spatial filters. If accurate a spatial filter my advice
It is that you implement your own evaluator.

So you say, I understand that the operation of "ST_Contains" that
want is between two fields of the table ... you could do something
as:

public class extends ContainsEvaluator AbstractEvaluator {

    @Override
    public Object evaluate (EvaluatorData data) throws EvaluatorException {
        try {
            Geometry Geoma = (Geometry) data.getDataValue ( "Geoma");
            Geometry geomB = (Geometry) data.getDataValue ( "geomB");
            if (null == || Geoma geomB == null) {
                return false;
            }
            geomA.contains return (geomB);
        } Catch (Exception ex) {
            throw new EvaluatorException (ex);
        }
    }

    @Override
    GetSQL public String () {
        return "ST_Contains (Geoma, geomB)";
    }

    @Override
    public String getName () {
        return "My Contains";
    }

}

This would be the way to do it until version 2.3 (included).

I recommend you read the article

https://blog.gvsig.org/2016/10/17/some-improvements-in-access-data-in-gvsig-2-4/

part of the "Create a filter for a DB That will be independent from itself".

If you do not understand something ... ask.

a greeting
Joaquin

-------------------------------------------------------------------

Hola Hanae,
Para usar filtros espaciales en las consultas, se usa una
clase que extienda de Evaluator. El metodo setFilter de
FeatureQuery es algo como:

void setFilter(Evaluator filter);

Cuando se utiliza el metodo createExpresion del DataManager se
crea un Evaluator especifico (SQLJEPEvaluator) que es capaz de
filtrar por condiciones alfanumericas, y aunque tiene soporte
para algunas funciones espaciales. Actualmente las funciones
espaciales soportadas son:

- GeomFromText
- Intersects
- Overlaps
- Boundary

Sin embargo no aconsejo el uso de este evaluador para realizar
filtros espaciales. Si precisas un filtro espacial mi consejo
es que implementes tu propio evaluador.

Por lo que pones, entiendo que la operacion de "ST_Contains" que
quieres seria entre dos campos de la tabla... se podria hacer algo
como:

public class ContainsEvaluator extends AbstractEvaluator {

    @Override
    public Object evaluate(EvaluatorData data) throws EvaluatorException {
        try {
            Geometry geomA = (Geometry) data.getDataValue("geomA");
            Geometry geomB = (Geometry) data.getDataValue("geomB");
            if( geomA==null || geomB==null ) {
                return false;
            }
            return geomA.contains(geomB);
        } catch (Exception ex) {
            throw new EvaluatorException(ex);
        }
    }

    @Override
    public String getSQL() {
        return "ST_Contains(geomA, geomB)";
    }

    @Override
    public String getName() {
        return "Mi Contains";
    }

}

Esta seria la forma de hacerlo hasta la version 2.3 (incluida).

Te recomiendo que leas el articulo

https://blog.gvsig.org/2016/10/17/some-improvements-in-access-data-in-gvsig-2-4/

la parte de "Create a filter for a DB that will be independent from itself".

Si no entiendes algo... pregunta.

Un saludo
Joaquin

 
thanks


_______________________________________________
gvSIG-desktop-devel mailing list
http://joinup.ec.europa.eu/mailman/listinfo/gvsig-desktop-devel



--
--------------------------------------
Joaquin Jose del Cerro Murciano
Development and software arquitecture manager at gvSIG Team
[hidden email]
[hidden email]
gvSIG Association
www.gvsig.com
www.gvsig.org

_______________________________________________
gvSIG-desktop-devel mailing list
http://joinup.ec.europa.eu/mailman/listinfo/gvsig-desktop-devel
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Joaquin Jose del Cerro Murciano

Sorry, the java code would be as follows:

public class ContainsEvaluator extends AbstractEvaluator {

    @Override
    public Object evaluate(EvaluatorData data) throws EvaluatorException {
        try {
            Geometry geomA = (Geometry) data.getDataValue("geomA");
            Geometry geomB = (Geometry) data.getDataValue("geomB");
            if( geomA==null || geomB==null ) {
                return false;
            }
            return geomA.contains(geomB);
        } catch (Exception ex) {
            throw new EvaluatorException(ex);
        }
    }

    @Override
    public String getSQL() {
        return "ST_Contains(geomA, geomB)";
    }

    @Override
    public String getName() {
        return "Mi Contains";
    }

}

the translation had spoiled.

2016-10-19 12:28 GMT+02:00 Joaquin Jose del Cerro Murciano <[hidden email]>:


2016-10-19 10:51 GMT+02:00 hanae bourziza <[hidden email]>:

Hi,

I am having some issues writing a sql query that uses the Postgis function ST_Contains(geometry geomA, geometry geomB) 

FeatureQuery query = store.createFeatureQuery();
query.setFilter( manager.createExpresion("ST_Contains(geomA, geomB)") );
I am getting this error org.medfoster.sqljep.parseexception, could anyone help?


Hello Hanae,
To use spatial filters in querys, use a
class that extends Evaluator. The method setFilter in
FeatureQuery is something like:

void setFilter (Evaluator filter);

The createExpresion method of DataManager
creates a specific Evaluator (SQLJEPEvaluator) that is capable of
filter by alphanumeric conditions, and although it has spatial support
for some functions. Currently the spatial functions
supported are:

- GeomFromText
- Intersects
- Overlaps
- Boundary

However I would not advise using this evaluator for
spatial filters. If accurate a spatial filter my advice
It is that you implement your own evaluator.

So you say, I understand that the operation of "ST_Contains" that
want is between two fields of the table ... you could do something
as:

public class extends ContainsEvaluator AbstractEvaluator {

    @Override
    public Object evaluate (EvaluatorData data) throws EvaluatorException {
        try {
            Geometry Geoma = (Geometry) data.getDataValue ( "Geoma");
            Geometry geomB = (Geometry) data.getDataValue ( "geomB");
            if (null == || Geoma geomB == null) {
                return false;
            }
            geomA.contains return (geomB);
        } Catch (Exception ex) {
            throw new EvaluatorException (ex);
        }
    }

    @Override
    GetSQL public String () {
        return "ST_Contains (Geoma, geomB)";
    }

    @Override
    public String getName () {
        return "My Contains";
    }

}

This would be the way to do it until version 2.3 (included).

I recommend you read the article

https://blog.gvsig.org/2016/10/17/some-improvements-in-access-data-in-gvsig-2-4/

part of the "Create a filter for a DB That will be independent from itself".

If you do not understand something ... ask.

a greeting
Joaquin

-------------------------------------------------------------------

Hola Hanae,
Para usar filtros espaciales en las consultas, se usa una
clase que extienda de Evaluator. El metodo setFilter de
FeatureQuery es algo como:

void setFilter(Evaluator filter);

Cuando se utiliza el metodo createExpresion del DataManager se
crea un Evaluator especifico (SQLJEPEvaluator) que es capaz de
filtrar por condiciones alfanumericas, y aunque tiene soporte
para algunas funciones espaciales. Actualmente las funciones
espaciales soportadas son:

- GeomFromText
- Intersects
- Overlaps
- Boundary

Sin embargo no aconsejo el uso de este evaluador para realizar
filtros espaciales. Si precisas un filtro espacial mi consejo
es que implementes tu propio evaluador.

Por lo que pones, entiendo que la operacion de "ST_Contains" que
quieres seria entre dos campos de la tabla... se podria hacer algo
como:

public class ContainsEvaluator extends AbstractEvaluator {

    @Override
    public Object evaluate(EvaluatorData data) throws EvaluatorException {
        try {
            Geometry geomA = (Geometry) data.getDataValue("geomA");
            Geometry geomB = (Geometry) data.getDataValue("geomB");
            if( geomA==null || geomB==null ) {
                return false;
            }
            return geomA.contains(geomB);
        } catch (Exception ex) {
            throw new EvaluatorException(ex);
        }
    }

    @Override
    public String getSQL() {
        return "ST_Contains(geomA, geomB)";
    }

    @Override
    public String getName() {
        return "Mi Contains";
    }

}

Esta seria la forma de hacerlo hasta la version 2.3 (incluida).

Te recomiendo que leas el articulo

https://blog.gvsig.org/2016/10/17/some-improvements-in-access-data-in-gvsig-2-4/

la parte de "Create a filter for a DB that will be independent from itself".

Si no entiendes algo... pregunta.

Un saludo
Joaquin

 
thanks


_______________________________________________
gvSIG-desktop-devel mailing list
http://joinup.ec.europa.eu/mailman/listinfo/gvsig-desktop-devel



--
--------------------------------------
Joaquin Jose del Cerro Murciano
Development and software arquitecture manager at gvSIG Team
[hidden email]
[hidden email]
gvSIG Association
www.gvsig.com
www.gvsig.org



--
--------------------------------------
Joaquin Jose del Cerro Murciano
Development and software arquitecture manager at gvSIG Team
[hidden email]
[hidden email]
gvSIG Association
www.gvsig.com
www.gvsig.org

_______________________________________________
gvSIG-desktop-devel mailing list
http://joinup.ec.europa.eu/mailman/listinfo/gvsig-desktop-devel