how can i visualize generated spline curve?

799 views
Skip to first unread message

Sphere

unread,
Mar 9, 2010, 4:58:25 AM3/9/10
to KML Developer Support - Google Earth Plug-in
Hello,

i have two questions:
i would like to visualize this example (http://docs.codehaus.org/
display/GEOTDOC/01+How+to+Create+a+Geometry#01HowtoCreateaGeometry-
CreatingaPoint)
but i don't know how?
Second, i would like to display this example in google earth.
Or is there any Tutorial about these?

Can your please help me.

Thanks in advance,
Sphere

Coordinate[] myPoints = new Coordinate[] {
new Coordinate(0,0),
new Coordinate(3,6),
new Coordinate(9,12),
new Coordinate(12,6),
new Coordinate(15,4),
new Coordinate(20,10),
new Coordinate(26,18),
new Coordinate(29,16),
new Coordinate(32,13),
new Coordinate(37,18),
new Coordinate(43,24),
new Coordinate(50,16)
};

SplineInterpolator si = new SplineInterpolator();

// generate a curve represented by 100 points plus the input points
Coordinate[] interpPoints = si.interpolate(myPoints, 100, true);

GeometryFactory gf = new GeometryFactory();
gf.createLineString(coords.toArray(new Coordinate[coords.size()]));

fraser (Earth API Guru)

unread,
Mar 9, 2010, 6:19:49 AM3/9/10
to KML Developer Support - Google Earth Plug-in
Hi,

I would read the page on Geometries and Overlays here:
http://code.google.com/apis/earth/documentation/geometries.html#linestring

Also check the demo gallery here:
http://code.google.com/apis/earth/documentation/demogallery.html

And set the category to Geometries, there are lots of examples to work
from.

Hope that helps,

F.

Nymor

unread,
Mar 9, 2010, 9:54:04 PM3/9/10
to KML Developer Support - Google Earth Plug-in
Hi Sphere,

Not sure what exactly the the example you linked to is - it's not a
language I'm familiar with - but the mention of Splines in the topic
title got me in here.

I'm going to make a huge leap here and assume you want to show a
linestring in GE, given various co-ordinates along it, as a smooth
curve rather than a series of straight lines joining those co-ords?

As it stands there's nothing available native within GE that helps you
do that - it will draw straight lines from point-to-point using the
values in the co-ordinates tag.

However don't let that put you off if you want smooth curves. I've
been using them within my KMLs for a few years and it works fairly
well - however you have to do the work that you would otherwise hope
GE does. By that I mean you will have to calculate the additional
points within the curve.

I use VBA to do mine (within an Access database) and I take 4, or more
original co-ords, (the method I use requires a minimum of 4) and add 9
more between each pair using Bezier Spline calculations. I started
doing this a few years ago and for the life of me can't remember where
I found the code that I adapted but it was something written in Excel
VBA that demostrated how Excel draws smooth curves in graphs. You
should be able to find similar code examples (maybe the one you linked
to?) in the language you need it in to do the job for you. If you
initial points are relatively close together (ie not 10/100s km apart)
then you can ignore the fact that the World is round and just use the
lat/lng as though they are on a flat plane.

It just so happens that I'm working with Bezier curves as we speak as
I'm updating my F1 Racing collection, for the start of the new season
this weekend, and that uses this method heavily. An example of what I
get can be found at
http://www.thekmz.co.uk/misc/ge_bezier_1.png
... the Red line (and co-ords) is my initial Linestring and the White
one is a linestring produced after I apply my Bezier code to it. (Each
Red segment translates to 11 points on the White path).

Obviously I could re-bezier the White line to add even more points if
my initial ones were further apart.

So in short - yes it can be done but GE won't do it for you you'll
have to find some code in whatever language you use and then create a
new (smoothed) path from that.

Good Luck and I hope that helps in some way.

Regards
Nymor.


ps. Hi Fraser - long time no see :) - hope all is well and this is not
just a fleeting visit.

Sphere

unread,
Mar 11, 2010, 4:56:10 AM3/11/10
to KML Developer Support - Google Earth Plug-in
Hello,

thank you for your answer.

The problem ist that i am totally limited with "LineString" in google
Earth, therefore i cannot use Spline funktion on it (i tried it but it
didn't work).

Sphere.

On 9 Mrz., 12:19, fraser (Earth API Guru) wrote:
> Hi,
>

> I would read the page on Geometries and Overlays here:http://code.google.com/apis/earth/documentation/geometries.html#lines...

Sphere

unread,
Mar 11, 2010, 5:50:28 AM3/11/10
to KML Developer Support - Google Earth Plug-in
Hello Nymor,

thanks alot for your full description and your time. I am very
appriciated for that.

My goal is:
1) reading IGC Data from GPS from Java
2) Converting IGC Data to KML (as 3D) from Java
3) then showing the Track in G.E. (as 3D)
1)+2) i am using GeoTools API

After reading your email, i found this code under http://www.nrbook.com/nr3/
->Chapter3 (Cube Spline)
i adapted this code and it works :-))

3) Now, I would like to coloring my Track in google Earth per
dieferrent height. I am mean, when the Track goes up, it should be
i.e. blue and if the track is going down (near earth), it should be
red. Do you have please an idea, how can i do it?

4) Visualizing polygon on all over my Track in G.E., either horizontal
or vertical. I wrote polygon in java. My problem is: when i am going
in the near of my polygon on the Track, my polygone will
diappear !!!!!!!!! . I don't know why.
I did try with another simple example . The result is the same. The
Object (Cube, Triangle, Building...) will be disappear. Is is because
of "setting of Goolge Earth" or should i have to turne on/off
something in Google earth?

Many Thanks in advance for help.

Best regards,
Sphere

> get can be found athttp://www.thekmz.co.uk/misc/ge_bezier_1.png

StarTraX

unread,
Mar 11, 2010, 4:55:59 PM3/11/10
to KML Developer Support - Google Earth Plug-in
I'm following this thread with interest as I'm also looking to smooth
tracks - GPS points tend to be very angular and following them can be
very jerky!
I suspect your problem, Sphere, with disappearing polygons is another
example of the "near clipping plane" bug in GE
http://code.google.com/p/earth-api-samples/issues/detail?id=120&colspec=ID%20Type%20Summary%20Component%20OpSys%20Browser%20Status%20Stars%20Internal

I am reading the NRBook (above), but am finding it very hard going (I
did my degree in Maths/Physics 45 yrs ago!), so would really
appreciate some assistance to find the code that will
interpolate a cubic curve between two points given the tangents at
each end (I know that would generate an infinity of curves, so it
needs a further parameter to select one)

Cheers,


On Mar 11, 9:50 pm, Sphere wrote:
> Hello Nymor,
>
> thanks alot for your full description and your time. I am very
> appriciated for that.
>
> My goal is:
> 1) reading IGC Data from GPS from Java
> 2) Converting IGC Data to KML (as 3D) from Java
> 3) then showing the Track in G.E.   (as 3D)
> 1)+2) i am using GeoTools API
>

> After reading your email, i found this code underhttp://www.nrbook.com/nr3/

Forrest

unread,
Mar 13, 2010, 10:53:13 AM3/13/10
to KML Developer Support - Google Earth Plug-in
Howdy,
note that I recently went to the Google Maps API class offered by
Marakana (out of San Fran)... first time the class has been conducted
outside of Google...

Marakana had some code document in the class book (author Thor
Mitchell), that might do the trick for you, from a guy named Chris
Veness:

//****** GET BEARING BETWEEN RED MARKER AND NEAREST PANO ************
// Functions below attributed to Chris Veness cpy 2002-2009
// www.movable-type.co.uk/scripts/latlong.html
// Plagarized script directly from Google/Marakana training
materials.
function getBearing(latlng1, latlng2) {
// called from the openPanoramaBubble function
//alert("determining bearing");
lat1 = latlng1.lat().toRad();
lat2 = latlng2.lat().toRad();
var dLon = (latlng2.lng()-latlng1.lng()).toRad();
//
var y = Math.sin(dLon) * Math.cos(lat2);
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) *
Math.cos(lat2) * Math.cos(dLon);
return Math.atan2(y, x).toBrng();
} // end getBearing function
//
Number.prototype.toRad = function() {
return this * Math.PI / 180;
} // end prototype toRad
//
Number.prototype.toBrng = function() {
return ((this * 180 / Math.PI)+360) % 360;
} // end prototype toBrng
//
//*******************************************************************


On Mar 11, 1:55 pm, StarTraX wrote:
> I'm following this thread with interest as I'm also looking to smooth
> tracks - GPS points tend to be very angular and following them can be
> very jerky!
> I suspect your problem, Sphere, with disappearing polygons is another

> example of the "near clipping plane" bug in GEhttp://code.google.com/p/earth-api-samples/issues/detail?id=120&colsp...

Reply all
Reply to author
Forward
0 new messages