Effective way to check if a location is inside a rectangular perimeter?

First, I will talk about the problem: I am developing an application in which I have to show the map field and overlay markers and lines. However, in BlacBerry OS 5.0, the only one MapFieldavailable in the API does not provide tools for overlaying material, it only shows a map in place. It also provides methods for converting screen coordinates (pixels) to / from WGS84 coordinates. These methods can be expensive.

To draw my own elements, I need to extend this class and override its paint () method. The expanding class will also contain a collection of locations. This will look like the overriden method (I will use Java here):

        public void paint (Graphics g) {
            super.paint(g); //draws the map

            //TODO
            //Draw placemarks. The placemarks are basically holder objects
            //(for latitude and longitude) stored in a collection in this class.
        }

However, to draw these objects on the screen, we must first convert the locations of the labels (lat, long) to the coordinates of the screen (x, y in pixels). This can not be done in advance, since the map is not static, so it allows you to scroll and zoom. That is why in each cycle of paint we must draw at least VISIBLE OBJECTS. However, my question is:

For a rectangular perimeter where the corners are geographic locations (transformed by the four corners of the part of the map currently being displayed), is there a quick method for looping around each mark in the collection and determining whether they are visible or not?

, 100% , , . (< 100), , , , , , .

, , : , . +180 +90. , , , ( -180 +180 -90 +90 ), . , , , , , .

, , ( x = 0, y = 0), , , 4 ( ), .

.

.

+3
3

: "", . . (x,y,z):

x = cos[long] cos[lat]
y = sin[long] cos[lat]
z = sin[lat] 

(x,y,z) (, (0,0,0), - ). "" ( , , , ). (xMiddle,yMiddle,zMiddle), , (x,y,z), (xMiddle,yMiddle,zMiddle) .

, (xMiddle,yMiddle,zMiddle) , (xMiddle,yMiddle,zMiddle).

.

+3

. , , . , . , +/- 180 , . +/- 90, , 4D, ?; -)

1, : , , . , , , , . , , .. . , , , . .

2, , +/- 180: / . , , .

3, , +/- 180: , . , +180 -180 . min/max , .

2 3 . 1 -, , , - . , - , . - , .

+2

, . , .

, , . , , - , , , .

"3d" .

0

All Articles