Re: [OpenMap Users] Graphics object to draw

From: Tony Vasile <avasile_at_csc.com.au>
Date: Tue, 29 Sep 2009 15:32:42 +1100

Hi Don,
   I have included the below code in my code but one thing I notice now is
that after going from 4.5.4 to 4.6.5 that I have to explicitly create a
LayerHandler for my Canvas object which extends BasicMapPanel . Also my
layer which I add to this object via a call to the object's MapHandler.add
method it seems that the only layer present is the one I add via the
compiled code rather than the graticule layer which I specify in my
openmap.properties file and my layer. One other thing is that the
background on my layer used to be black and now it is grey. I don't have
any explicit calls to set the background of my layer.

Any help would be most appreciated.

Tony Vasile
Senior Software Engineer
CSC

Level 3B, 26 Talavera Road Macquarie Park NSW 2113 Australia
GBS | p: +61 2 9034 2404 | f: +61 2 9034 2404 | avasile_at_csc.com |
www.csc.com


Please consider the environment before printing this e-mail.

CSC - This is a private message. If you are not the intended recipient,
please delete without copying and kindly advise us by e-mail of the
mistake in delivery. Note: Regardless of content, this e-mail shall not
operate to bind CSC to any order or other contract unless pursuant to
explicit written agreement or government initiative expressly permitting
the use of e-mail for such purpose - CSC Australia Pty Limited; Registered
Office: 5B/26 Talavera Road, Macquarie Park NSW 2113 Australia;
Incorporated in Australia. ACN: 008 476 944




Don Dietrick <dietrick_at_bbn.com>
16/09/2009 05:23 AM

To
Tony Vasile <avasile_at_csc.com.au>
cc
openmap-users_at_bbn.com
Subject
Re: [OpenMap Users] Graphics object to draw





Hi Tony,

You are on the right track with using an OMGraphicList.

I thought this would be easier to figure out, but I ended up adding a
method to the GreatCircle class to help with this. If you are using
the beta, the code will be updating into the repository shortly. If
you are using OpenMap 4.6.5, you can just add this code somewhere:

-----------------------------------------------------------
/**
* Return a point that is approximately a certain distance along
the great
* circle line between two points. Returns the nearest coordinate
along a
* set of calculated segments (as dictated by n) that fits the
desired
* distance.
*
* _at_param phi1 latitude of point 1 in radians.
* _at_param lambda0 longitude of point 1 in radians.
* _at_param phi latitude of point 2 in radians.
* _at_param lambda longitude of point 2 in radians.
* _at_param distance in radians.
* _at_param n number of segments to divide path into. The more
segments, the
* more accurate. If n <= 0, the OpenMap default of 512 is
used.
* _at_return LatLonPoint if distance is less than distance between
points,
* null if it is greater.
*/
public LatLonPoint pointAtDistanceBetweenPoints(double phi1,
double
lambda0,
double phi,
double
lambda,
double
distance,
int n) {
LatLonPoint ret = null;

double pntDist = GreatCircle.sphericalDistance(phi1, lambda0,
phi, lambda);

if (pntDist > distance) {
if (n <= 0) {
n = GeoProj.NUM_DEFAULT_GREAT_SEGS;
}

double[] gcpoints = GreatCircle.greatCircle(phi1,
lambda0, phi, lambda, n, true);

// Ratio of desired distance to total distance between
points - how
// far down the line we need to go.
double distRatio = distance / pntDist;
// all lat, lon points, get number of vertices, find
index of the
// one that fits the ratio of the desired distance to the
overall
// distance between points, and then multiply by 2 to get
the actual
// index of the matching latitude.
int index = (int) ((int) (gcpoints.length / 2) *
distRatio) * 2;
ret = new LatLonPoint.Double(gcpoints[index], gcpoints
[index + 1], true);
}

return ret;
}

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


Then, I just did this to create the OMLine/Circles in DemoLayer:

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

OMGraphicList geoTest = new OMGraphicList();
LatLonPoint pnt1 = new LatLonPoint.Double(42.0, -71.0);
LatLonPoint pnt2 = new LatLonPoint.Double(42.3, -70.678);
double gspacing = Length.MILE.toRadians(5);

OMCircle ompoint1 = new OMCircle(pnt1.getLatitude(),
pnt1.getLongitude(), gspacing, Length.RADIAN);
OMCircle ompoint2 = new OMCircle(pnt2.getLatitude(),
pnt2.getLongitude(), gspacing, Length.RADIAN);

LatLonPoint int1 = GreatCircle.pointAtDistanceBetweenPoints
(pnt1.getRadLat(),
pnt1.getRadLon(),
pnt2.getRadLat(),
pnt2.getRadLon(),
gspacing,
-1);
LatLonPoint int2 = GreatCircle.pointAtDistanceBetweenPoints
(pnt2.getRadLat(),
pnt2.getRadLon(),
pnt1.getRadLat(),
pnt1.getRadLon(),
gspacing,
-1);

OMLine geoline = new OMLine(int1.getLatitude(),
int1.getLongitude(), int2.getLatitude(), int2.getLongitude(),
OMGraphic.LINETYPE_GREATCIRCLE);
ompoint1.setLinePaint(Color.red);
ompoint2.setLinePaint(Color.red);
geoline.setLinePaint(Color.red);
geoTest.add(ompoint1);
geoTest.add(ompoint2);
geoTest.add(geoline);

logger.info("adding geoTest");
omList.add(geoTest);

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

Hope this helps,

- Don


On Sep 15, 2009, at 4:17 AM, Tony Vasile wrote:

>
> Hi
>
> I need to draw a specific object which consists of a line from a
> known position and at the end of the line a circle is drawn. The
> centre of the circle is the end of the line and I want the visible
> line to be reduced by this radius. On the circle there are also four
> short lines at the various poles i.e 0 degrees, 90 degrees, 180
> degrees and 270 degrees. I had thought about creating either a
> OMGraphicsList object with each of the components as part of the list.
>
> The only thing I need to know is the intersection point of the
> circle and the line to work out where the actual end of the
> truncated line will be.
>
> Any help would be most appreciated. Thanks in advance.
>
> Tony Vasile
> Senior Software Engineer
> CSC
>
> Level 3B, 26 Talavera Road Macquarie Park NSW 2113 Australia
>
>
> Please consider the environment before printing this e-mail.
>
> CSC - This is a private message. If you are not the intended
> recipient, please delete without copying and kindly advise us by e-
> mail of the mistake in delivery. Note: Regardless of content, this
> e-mail shall not operate to bind CSC to any order or other contract
> unless pursuant to explicit written agreement or government
> initiative expressly permitting the use of e-mail for such purpose -
> CSC Australia Pty Limited; Registered Office: 5B/26 Talavera Road,
> Macquarie Park NSW 2113 Australia; Incorporated in Australia. ACN:
> 008 476 944




--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Sep 29 2009 - 00:41:01 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT