I am trying to draw a regular OMPoly with markings evenly spaced on the
Polygon
(like a railroad line).
First I tried just drawing the OMPoly and then (using xpoints and
ypoints from the OMPoly),
I would evenly divide the poly in segments and then draw a slash at each
point.
This worked fine except when I would draw a very large OMPoly and then
zoom in very close.
I would be drawing stuff offscreen and it would take too long for it all
to render.
I then tried to only draw my slashes on the visible portion of the
OMPoly. Here is where my
problems arose. I am having difficulty determining which parts of the
OMPoly are visible on the screen.
When I zoom in tight on the OMPoly (scale < 10000), my code says that no
portion of the OMPoly
is on the screen, even though I can see it! Has anyone tried something
like this? Here's a snippet of my
code to find the visible segments...
*****************************
Rectangle rect = new Rectangle(new Point(0, 0), mapBean.getSize());
for(i = 0; i < xpoints.length; i++) {
int length2 = xpoints[i].length;
for(j = 0; j < length2 - 1; j++) {
//Get a line segment of the total poly.
int x1 = xpoints[i][j];
int y1 = ypoints[i][j];
int x2 = xpoints[i][j+1];
int y2 = ypoints[i][j+1];
//test the retangle, 'rect' is visible area
if(rect.contains(x1, y1) ||
rect.contains(x2, y2) ||
rect.intersectsLine(x1, y1, x2, y1)) {
System.out.println(rect + " intersects " + x1 + " " + y1 + " "
+ x2 + " " + y2);
} else {
System.out.println(rect + " does not intersect " + x1 + " " +
y1 + " " + x2 + " " + y2);
}
}
}
*****************************
-- Jeremy "Slacker" Zacker - "BLAH!" MCS Blk IV (732) 450-7066 -- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Mon Dec 24 10:51:29 2001
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:32 EDT