LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

5 messages Options
Embed this post
Permalink
Sebastien ARBOGAST

LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Reply Threaded More More options
Print post
Permalink
I have an application working with HibernateSpatial 1.0-SNAPSHOT and
Hibernate 3.2.5 on a PostgreSQL 8.2.5 with PostGis installed.

In my database, I have a PLACE table with a geometry-type column named
location. The Place class is mapped onto this table with the following
hibernate mapping configuration:

<property name="location" >
            <column name="LOCATION" not-null="true" unique="false"
sql-type="GEOMETRY"/>
            <type name="org.hibernatespatial.GeometryUserType">
            </type>
        </property>

With that mapping in place, I manage to persist place instances in the
database by using the following code:

Place place = this.getPlaceDao().create(..., new
com.vividsolutions.jts.geom.GeometryFactory().createPoint(new
com.vividsolutions.jts.geom.Coordinate(latitude, longitude,
altitude)));

...where latitude, longitude and altitude are double.

The persistence works OK and the inserted data for 12,14,16 looks like this:
01010000200000000000000000000028400000000000002C40

Now when I try to run a SQL query such as the following on the database:
select * from place where ST_distance_sphere(location,
ST_MakePoint(12,14,16)) < 10000

I get the following error:

ERROR:  LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Can anyone help me figure out what's wrong? Because there are many
different parts involved here and I'm really a newbie with GIS stuff.

Thx in advance.

--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Jeremy-78

Re: LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Reply Threaded More More options
Print post
Permalink
SRID is the spatial reference identifier that is used to store your
spatial data. A spatial reference system defines a projection,
coordinate system, datums and ellipsoids. You must know which SRID is
used in your spatial data stored in the database, and have the same
value in your Java Objects.

For the Java Objects, I think that you can set the SRID when you
create the GeometryFactory: see
http://www.jump-project.org/docs/jts/1.0/api/com/vividsolutions/jts/geom/GeometryFactory.html

For the database, I don't know how PostGreSQL is working but it should
not be difficult to find it.

Hope it helps,

Jim

---------- Forwarded message ----------
From: Sebastien ARBOGAST <[hidden email]>
Date: Jan 6, 2008 12:37 PM
Subject: [hibernatespatial-users] LWGEOM_distance_sphere Operation on
two GEOMETRIES with differenc SRIDs
To: [hidden email]


I have an application working with HibernateSpatial 1.0-SNAPSHOT and
Hibernate 3.2.5 on a PostgreSQL 8.2.5 with PostGis installed.

In my database, I have a PLACE table with a geometry-type column named
location. The Place class is mapped onto this table with the following
hibernate mapping configuration:

<property name="location" >
            <column name="LOCATION" not-null="true" unique="false"
sql-type="GEOMETRY"/>
            <type name="org.hibernatespatial.GeometryUserType">
            </type>
        </property>

With that mapping in place, I manage to persist place instances in the
database by using the following code:

Place place = this.getPlaceDao().create(..., new
com.vividsolutions.jts.geom.GeometryFactory().createPoint(new
com.vividsolutions.jts.geom.Coordinate(latitude, longitude,
altitude)));

...where latitude, longitude and altitude are double.

The persistence works OK and the inserted data for 12,14,16 looks like this:
01010000200000000000000000000028400000000000002C40

Now when I try to run a SQL query such as the following on the database:
select * from place where ST_distance_sphere(location,
ST_MakePoint(12,14,16)) < 10000

I get the following error:

ERROR:  LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Can anyone help me figure out what's wrong? Because there are many
different parts involved here and I'm really a newbie with GIS stuff.

Thx in advance.

--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Sebastien ARBOGAST

Re: LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Reply Threaded More More options
Print post
Permalink
OK, so as I haven't touched the SRID in the GeometryFactory, the
default one is 0.
Now I don't know what ST_MakePoint uses as a SRID, and I can't find a
way to specify it.

2008/1/7, Jeremy <[hidden email]>:

> SRID is the spatial reference identifier that is used to store your
> spatial data. A spatial reference system defines a projection,
> coordinate system, datums and ellipsoids. You must know which SRID is
> used in your spatial data stored in the database, and have the same
> value in your Java Objects.
>
> For the Java Objects, I think that you can set the SRID when you
> create the GeometryFactory: see
> http://www.jump-project.org/docs/jts/1.0/api/com/vividsolutions/jts/geom/GeometryFactory.html
>
> For the database, I don't know how PostGreSQL is working but it should
> not be difficult to find it.
>
> Hope it helps,
>
> Jim
>
> ---------- Forwarded message ----------
> From: Sebastien ARBOGAST <[hidden email]>
> Date: Jan 6, 2008 12:37 PM
> Subject: [hibernatespatial-users] LWGEOM_distance_sphere Operation on
> two GEOMETRIES with differenc SRIDs
> To: [hidden email]
>
>
> I have an application working with HibernateSpatial 1.0-SNAPSHOT and
> Hibernate 3.2.5 on a PostgreSQL 8.2.5 with PostGis installed.
>
> In my database, I have a PLACE table with a geometry-type column named
> location. The Place class is mapped onto this table with the following
> hibernate mapping configuration:
>
> <property name="location" >
>             <column name="LOCATION" not-null="true" unique="false"
> sql-type="GEOMETRY"/>
>             <type name="org.hibernatespatial.GeometryUserType">
>             </type>
>         </property>
>
> With that mapping in place, I manage to persist place instances in the
> database by using the following code:
>
> Place place = this.getPlaceDao().create(..., new
> com.vividsolutions.jts.geom.GeometryFactory().createPoint(new
> com.vividsolutions.jts.geom.Coordinate(latitude, longitude,
> altitude)));
>
> ...where latitude, longitude and altitude are double.
>
> The persistence works OK and the inserted data for 12,14,16 looks like this:
> 01010000200000000000000000000028400000000000002C40
>
> Now when I try to run a SQL query such as the following on the database:
> select * from place where ST_distance_sphere(location,
> ST_MakePoint(12,14,16)) < 10000
>
> I get the following error:
>
> ERROR:  LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs
>
> Can anyone help me figure out what's wrong? Because there are many
> different parts involved here and I'm really a newbie with GIS stuff.
>
> Thx in advance.
>
> --
> Sébastien Arbogast
>
> http://www.sebastien-arbogast.com
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>


--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Jeremy-78

Re: LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Reply Threaded More More options
Print post
Permalink
With a simple google search, I found that : "MakePoint used alone
creates a nontransformable geometry (one that has an SRID = -1, so
because of that, MakePoint is usually used in conjunction with SetSRID
to create a point geometry with spatial reference information)"

For example: SETSRID(MakePoint(-71.09405383923, 42.3151215523721),4326)

It is probably the same thing for ST_MakePoint(<x>, <y>, [<z>], [<m>])
and ST_SetSRID(geometry, integer).

Jim

On Jan 7, 2008 2:28 PM, Sebastien ARBOGAST <[hidden email]> wrote:

> OK, so as I haven't touched the SRID in the GeometryFactory, the
> default one is 0.
> Now I don't know what ST_MakePoint uses as a SRID, and I can't find a
> way to specify it.
>
> 2008/1/7, Jeremy <[hidden email]>:
>
> > SRID is the spatial reference identifier that is used to store your
> > spatial data. A spatial reference system defines a projection,
> > coordinate system, datums and ellipsoids. You must know which SRID is
> > used in your spatial data stored in the database, and have the same
> > value in your Java Objects.
> >
> > For the Java Objects, I think that you can set the SRID when you
> > create the GeometryFactory: see
> > http://www.jump-project.org/docs/jts/1.0/api/com/vividsolutions/jts/geom/GeometryFactory.html
> >
> > For the database, I don't know how PostGreSQL is working but it should
> > not be difficult to find it.
> >
> > Hope it helps,
> >
> > Jim
> >
> > ---------- Forwarded message ----------
> > From: Sebastien ARBOGAST <[hidden email]>
> > Date: Jan 6, 2008 12:37 PM
> > Subject: [hibernatespatial-users] LWGEOM_distance_sphere Operation on
> > two GEOMETRIES with differenc SRIDs
> > To: [hidden email]
> >
> >
> > I have an application working with HibernateSpatial 1.0-SNAPSHOT and
> > Hibernate 3.2.5 on a PostgreSQL 8.2.5 with PostGis installed.
> >
> > In my database, I have a PLACE table with a geometry-type column named
> > location. The Place class is mapped onto this table with the following
> > hibernate mapping configuration:
> >
> > <property name="location" >
> >             <column name="LOCATION" not-null="true" unique="false"
> > sql-type="GEOMETRY"/>
> >             <type name="org.hibernatespatial.GeometryUserType">
> >             </type>
> >         </property>
> >
> > With that mapping in place, I manage to persist place instances in the
> > database by using the following code:
> >
> > Place place = this.getPlaceDao().create(..., new
> > com.vividsolutions.jts.geom.GeometryFactory().createPoint(new
> > com.vividsolutions.jts.geom.Coordinate(latitude, longitude,
> > altitude)));
> >
> > ...where latitude, longitude and altitude are double.
> >
> > The persistence works OK and the inserted data for 12,14,16 looks like this:
> > 01010000200000000000000000000028400000000000002C40
> >
> > Now when I try to run a SQL query such as the following on the database:
> > select * from place where ST_distance_sphere(location,
> > ST_MakePoint(12,14,16)) < 10000
> >
> > I get the following error:
> >
> > ERROR:  LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs
> >
> > Can anyone help me figure out what's wrong? Because there are many
> > different parts involved here and I'm really a newbie with GIS stuff.
> >
> > Thx in advance.
> >
> > --
> > Sébastien Arbogast
> >
> > http://www.sebastien-arbogast.com
> > _______________________________________________
> > hibernatespatial-users mailing list
> > [hidden email]
> > http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> > _______________________________________________
> > hibernatespatial-users mailing list
> > [hidden email]
> > http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> >
>
>
> --
>
> Sébastien Arbogast
>
> http://www.sebastien-arbogast.com
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Sebastien ARBOGAST

Re: LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs

Reply Threaded More More options
Print post
Permalink
Woohooo! It works great!
Thanks a lot for your help Jim!

2008/1/7, Jeremy <[hidden email]>:

> With a simple google search, I found that : "MakePoint used alone
> creates a nontransformable geometry (one that has an SRID = -1, so
> because of that, MakePoint is usually used in conjunction with SetSRID
> to create a point geometry with spatial reference information)"
>
> For example: SETSRID(MakePoint(-71.09405383923, 42.3151215523721),4326)
>
> It is probably the same thing for ST_MakePoint(<x>, <y>, [<z>], [<m>])
> and ST_SetSRID(geometry, integer).
>
> Jim
>
> On Jan 7, 2008 2:28 PM, Sebastien ARBOGAST <[hidden email]> wrote:
> > OK, so as I haven't touched the SRID in the GeometryFactory, the
> > default one is 0.
> > Now I don't know what ST_MakePoint uses as a SRID, and I can't find a
> > way to specify it.
> >
> > 2008/1/7, Jeremy <[hidden email]>:
> >
> > > SRID is the spatial reference identifier that is used to store your
> > > spatial data. A spatial reference system defines a projection,
> > > coordinate system, datums and ellipsoids. You must know which SRID is
> > > used in your spatial data stored in the database, and have the same
> > > value in your Java Objects.
> > >
> > > For the Java Objects, I think that you can set the SRID when you
> > > create the GeometryFactory: see
> > > http://www.jump-project.org/docs/jts/1.0/api/com/vividsolutions/jts/geom/GeometryFactory.html
> > >
> > > For the database, I don't know how PostGreSQL is working but it should
> > > not be difficult to find it.
> > >
> > > Hope it helps,
> > >
> > > Jim
> > >
> > > ---------- Forwarded message ----------
> > > From: Sebastien ARBOGAST <[hidden email]>
> > > Date: Jan 6, 2008 12:37 PM
> > > Subject: [hibernatespatial-users] LWGEOM_distance_sphere Operation on
> > > two GEOMETRIES with differenc SRIDs
> > > To: [hidden email]
> > >
> > >
> > > I have an application working with HibernateSpatial 1.0-SNAPSHOT and
> > > Hibernate 3.2.5 on a PostgreSQL 8.2.5 with PostGis installed.
> > >
> > > In my database, I have a PLACE table with a geometry-type column named
> > > location. The Place class is mapped onto this table with the following
> > > hibernate mapping configuration:
> > >
> > > <property name="location" >
> > >             <column name="LOCATION" not-null="true" unique="false"
> > > sql-type="GEOMETRY"/>
> > >             <type name="org.hibernatespatial.GeometryUserType">
> > >             </type>
> > >         </property>
> > >
> > > With that mapping in place, I manage to persist place instances in the
> > > database by using the following code:
> > >
> > > Place place = this.getPlaceDao().create(..., new
> > > com.vividsolutions.jts.geom.GeometryFactory().createPoint(new
> > > com.vividsolutions.jts.geom.Coordinate(latitude, longitude,
> > > altitude)));
> > >
> > > ...where latitude, longitude and altitude are double.
> > >
> > > The persistence works OK and the inserted data for 12,14,16 looks like this:
> > > 01010000200000000000000000000028400000000000002C40
> > >
> > > Now when I try to run a SQL query such as the following on the database:
> > > select * from place where ST_distance_sphere(location,
> > > ST_MakePoint(12,14,16)) < 10000
> > >
> > > I get the following error:
> > >
> > > ERROR:  LWGEOM_distance_sphere Operation on two GEOMETRIES with differenc SRIDs
> > >
> > > Can anyone help me figure out what's wrong? Because there are many
> > > different parts involved here and I'm really a newbie with GIS stuff.
> > >
> > > Thx in advance.
> > >
> > > --
> > > Sébastien Arbogast
> > >
> > > http://www.sebastien-arbogast.com
> > > _______________________________________________
> > > hibernatespatial-users mailing list
> > > [hidden email]
> > > http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> > > _______________________________________________
> > > hibernatespatial-users mailing list
> > > [hidden email]
> > > http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> > >
> >
> >
> > --
> >
> > Sébastien Arbogast
> >
> > http://www.sebastien-arbogast.com
> > _______________________________________________
> > hibernatespatial-users mailing list
> > [hidden email]
> > http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
> >
> _______________________________________________
> hibernatespatial-users mailing list
> [hidden email]
> http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
>


--
Sébastien Arbogast

http://www.sebastien-arbogast.com
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users