basic questions

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

basic questions

roberto.caldas
I'm a beginner and have two questions I couldn't find the answer in documentation:

- Is it possible to define a projection system for my calculations? Example, I want to calculate the distance in km between two points that has coordinates in latitude/longitude degrees in a given projection system for Earth.

- I made a class that represents a moving object, so I used Coordinate implement its location (that changes all the time). I wanted to use Point, but Coordinate is the best class for dynamic info. So I'm instantiating a new Geometry everytime I need to perform calculation using this objects, is that right?

Thank you.
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: basic questions

mbedward
Hi Roberto,

For your first question, the short answer is that JTS works with
cartesian (planar) geometry so it won't deal correctly with distances
between points on the globe expressed as lat/long coords.  There are
various ways to do what you want.  See this recent discussion...
http://n2.nabble.com/Lat-lon-coordinate-systems.-td2275815.html

For your second question. If you have created a Coordinate object to
hold current position, you can always change the x and y values
without needing to construct a new object..

Coordinate c = new Coordinate();
c.x = ...
c.y = ...

// later
c.x = ...
c.y = ...

But perhaps I don't understand your question correctly.  If not,
please say so...

Hope this helps
Michael


2009/3/31  <[hidden email]>:

> I'm a beginner and have two questions I couldn't find the answer in
> documentation:
>
> - Is it possible to define a projection system for my calculations? Example,
> I want to calculate the distance in km between two points that has
> coordinates in latitude/longitude degrees in a given projection system for
> Earth.
>
> - I made a class that represents a moving object, so I used Coordinate
> implement its location (that changes all the time). I wanted to use Point,
> but Coordinate is the best class for dynamic info. So I'm instantiating a
> new Geometry everytime I need to perform calculation using this objects, is
> that right?
>
> Thank you.
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: basic questions

roberto.caldas
Hello Michael

Thank you for your answer!
About my second question, I want to know if I'm doing the right thing (most efficient): I want to have the "dynamic" characteristic of Coordinate (i.e., change values) but I also want to have the funcionality of Point, want to use the geometric operations. So I think I must use Coordinate in my class and then instantiate a Point/Geometry with the coordinate's value everytime I need to perform a calculation. Is that right?

Roberto


On Mar 30, 2009 8:05pm, Michael Bedward <[hidden email]> wrote:

> Hi Roberto,
>
>
>
> For your first question, the short answer is that JTS works with
>
> cartesian (planar) geometry so it won't deal correctly with distances
>
> between points on the globe expressed as lat/long coords.  There are
>
> various ways to do what you want.  See this recent discussion...
>
> http://n2.nabble.com/Lat-lon-coordinate-systems.-td2275815.html
>
>
>
> For your second question. If you have created a Coordinate object to
>
> hold current position, you can always change the x and y values
>
> without needing to construct a new object..
>
>
>
> Coordinate c = new Coordinate();
>
> c.x = ...
>
> c.y = ...
>
>
>
> // later
>
> c.x = ...
>
> c.y = ...
>
>
>
> But perhaps I don't understand your question correctly.  If not,
>
> please say so...
>
>
>
> Hope this helps
>
> Michael
>
>
>
>
>
> 2009/3/31  [hidden email]>:
>
> > I'm a beginner and have two questions I couldn't find the answer in
>
> > documentation:
>
> >
>
> > - Is it possible to define a projection system for my calculations? Example,
>
> > I want to calculate the distance in km between two points that has
>
> > coordinates in latitude/longitude degrees in a given projection system for
>
> > Earth.
>
> >
>
> > - I made a class that represents a moving object, so I used Coordinate
>
> > implement its location (that changes all the time). I wanted to use Point,
>
> > but Coordinate is the best class for dynamic info. So I'm instantiating a
>
> > new Geometry everytime I need to perform calculation using this objects, is
>
> > that right?
>
> >
>
> > Thank you.
>
> > _______________________________________________
>
> > jts-devel mailing list
>
> > [hidden email]
>
> > http://lists.refractions.net/mailman/listinfo/jts-devel
>
> >
>
> >
>
> _______________________________________________
>
> jts-devel mailing list
>
> [hidden email]
>
> http://lists.refractions.net/mailman/listinfo/jts-devel
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: basic questions

Sunburned Surveyor
Roberto:

Michael wrote: "For your first question, the short answer is that JTS works with
cartesian (planar) geometry so it won't deal correctly with distances
between points on the globe expressed as lat/long coords.  There are
various ways to do what you want."

One of the techniques Michael was talking about is to project your
lat/long data into a grid coordinate system. Once this conversion is
completed you can use JTS. JTS isn't really made to work with geodetic
coordinates directly, at least not over large areas.

You need to:

[1] Convert your geodetic data to grid/plane data.
[2] Manipulate your grid data in JTS.
[3] Convert back to geodetic data if needed.

You can use GeoTools or the deegree Project libraries to accomplish
your conversions from geodetic to grid. Just make sure you understand
the distortions of the map projection you select.

Roberto wrote: "About my second question, I want to know if I'm doing
the right thing (most efficient): I want to have the "dynamic"
characteristic of Coordinate (i.e., change values) but I also want to
have the funcionality of Point, want to use the geometric operations.
So I think I must use Coordinate in my class and then instantiate a
Point/Geometry with the coordinate's value everytime I need to perform
a calculation. Is that right?"

I think there may be a more efficient way to accomplish what you seek.
Create a CoordinateFilter implementation and call the
apply(CoordinateFilter argFilter) method of the Point class to
complete the translation you desire. I think I have a CoordinateFilter
implementation whipped up that will do this. I can share it if you
like, but it shouldn't be that hard to write.

The Sunburned Surveyor

On Tue, Mar 31, 2009 at 5:15 AM,  <[hidden email]> wrote:

> Hello Michael
>
> Thank you for your answer!
> About my second question, I want to know if I'm doing the right thing (most
> efficient): I want to have the "dynamic" characteristic of Coordinate (i.e.,
> change values) but I also want to have the funcionality of Point, want to
> use the geometric operations. So I think I must use Coordinate in my class
> and then instantiate a Point/Geometry with the coordinate's value everytime
> I need to perform a calculation. Is that right?
>
> Roberto
>
>
> On Mar 30, 2009 8:05pm, Michael Bedward <[hidden email]> wrote:
>> Hi Roberto,
>>
>>
>>
>> For your first question, the short answer is that JTS works with
>>
>> cartesian (planar) geometry so it won't deal correctly with distances
>>
>> between points on the globe expressed as lat/long coords.  There are
>>
>> various ways to do what you want.  See this recent discussion...
>>
>> http://n2.nabble.com/Lat-lon-coordinate-systems.-td2275815.html
>>
>>
>>
>> For your second question. If you have created a Coordinate object to
>>
>> hold current position, you can always change the x and y values
>>
>> without needing to construct a new object..
>>
>>
>>
>> Coordinate c = new Coordinate();
>>
>> c.x = ...
>>
>> c.y = ...
>>
>>
>>
>> // later
>>
>> c.x = ...
>>
>> c.y = ...
>>
>>
>>
>> But perhaps I don't understand your question correctly.  If not,
>>
>> please say so...
>>
>>
>>
>> Hope this helps
>>
>> Michael
>>
>>
>>
>>
>>
>> 2009/3/31  [hidden email]>:
>>
>> > I'm a beginner and have two questions I couldn't find the answer in
>>
>> > documentation:
>>
>> >
>>
>> > - Is it possible to define a projection system for my calculations?
>> > Example,
>>
>> > I want to calculate the distance in km between two points that has
>>
>> > coordinates in latitude/longitude degrees in a given projection system
>> > for
>>
>> > Earth.
>>
>> >
>>
>> > - I made a class that represents a moving object, so I used Coordinate
>>
>> > implement its location (that changes all the time). I wanted to use
>> > Point,
>>
>> > but Coordinate is the best class for dynamic info. So I'm instantiating
>> > a
>>
>> > new Geometry everytime I need to perform calculation using this objects,
>> > is
>>
>> > that right?
>>
>> >
>>
>> > Thank you.
>>
>> > _______________________________________________
>>
>> > jts-devel mailing list
>>
>> > [hidden email]
>>
>> > http://lists.refractions.net/mailman/listinfo/jts-devel
>>
>> >
>>
>> >
>>
>> _______________________________________________
>>
>> jts-devel mailing list
>>
>> [hidden email]
>>
>> http://lists.refractions.net/mailman/listinfo/jts-devel
>>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Re: basic questions

roberto.caldas
Sunburned Surveyor

Thank you for answering. I'm going to study GeoTools and take a look at deegree.

For the filter you suggested, do you mean my code to change the point's coordinate would be something like this?

...

MyCoordinateFilter filter = new MyCoordinateFilter();
filter.setX(97);
filter.setY(98);

point.apply(filter);
point.geometryChanged(); // <-- really necessary?
}

Roberto
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Re: basic questions

Sunburned Surveyor
Robert,

Your code looks to be right on the money. I do think the call to
geometryChanged is necessary, but I can't remember why off the top of
my head.

Landon

On Tue, Mar 31, 2009 at 12:06 PM,  <[hidden email]> wrote:

> Sunburned Surveyor
>
> Thank you for answering. I'm going to study GeoTools and take a look at
> deegree.
>
> For the filter you suggested, do you mean my code to change the point's
> coordinate would be something like this?
>
> ...
>
> MyCoordinateFilter filter = new MyCoordinateFilter();
> filter.setX(97);
> filter.setY(98);
>
> point.apply(filter);
> point.geometryChanged(); // <-- really necessary?
> }
>
> Roberto
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Re: basic questions

Sunburned Surveyor
In reply to this post by roberto.caldas
Robert,

Your code looks to be right on the money. I do think the call to
geometryChanged is necessary, but I can't remember why off the top of
my head.

Landon

On Tue, Mar 31, 2009 at 12:06 PM,  <[hidden email]> wrote:

> Sunburned Surveyor
>
> Thank you for answering. I'm going to study GeoTools and take a look at
> deegree.
>
> For the filter you suggested, do you mean my code to change the point's
> coordinate would be something like this?
>
> ...
>
> MyCoordinateFilter filter = new MyCoordinateFilter();
> filter.setX(97);
> filter.setY(98);
>
> point.apply(filter);
> point.geometryChanged(); // <-- really necessary?
> }
>
> Roberto
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>
>
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: basic questions

Stefan Steiniger
In reply to this post by roberto.caldas
geometry changed needs to be called I think - to recalculate the new
envelope or so

stefan

In OpenJUMP there are a couple of example for Coordinate Filter use,
e.g. in org.openjump.core.ui.plugin.mousemenu.MoveAlongAnglePlugIn
_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: basic questions

Martin Davis
In reply to this post by roberto.caldas
#1: as others have replied, JTS operates purely on a Cartesian plane.  
It does not perform calculations in a spherical or spheroidal space.

#2: as mentioned by others, easiest way is to modify the underlying
Coordinate of a Point geometry.  If you do this, you need to call
geiometryChanged() to update the cached information in the Geometry (the
Envelope at the moment).  Be aware that of course any references to this
geometry will not be aware of this change, so you will have to update
them as required (e.g. JTS indexes are not aware of changes to contained
geometries).

Generally it's not encouraged to modify Geometry objects, since this can
lead to nasty aliasing bugs, but it's not prevented for just this reason
- in some cases it's more efficient to modify geometry objects in place.

[hidden email] wrote:

> I'm a beginner and have two questions I couldn't find the answer in
> documentation:
>
> - Is it possible to define a projection system for my calculations?
> Example, I want to calculate the distance in km between two points
> that has coordinates in latitude/longitude degrees in a given
> projection system for Earth.
>
> - I made a class that represents a moving object, so I used Coordinate
> implement its location (that changes all the time). I wanted to use
> Point, but Coordinate is the best class for dynamic info. So I'm
> instantiating a new Geometry everytime I need to perform calculation
> using this objects, is that right?
>
> Thank you.
> ------------------------------------------------------------------------
>
> _______________________________________________
> jts-devel mailing list
> [hidden email]
> http://lists.refractions.net/mailman/listinfo/jts-devel
>  

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/jts-devel
Loading...