What is a best way to find features inside another feature (polygon)? I’m currently using SpatialQuery - QueryType.Within, but it does not work if polygon crosses dateline or on “virtual” world.
The reason is that the feature in trackOverlay is real value and the features displayed on the virtual world are "virtual value", their value are always in (-180,180), so if you want to query the features near the dateline, you should shift the polygon to the real world and query.
I know there are a lot of samples in this forum regarding the dateline issue, but none of them work 100% right. Is it a lot to ask you to provide a working example that able to do the following (based on my sample code)? 1. Select a polygon on a map that crosses 180 (already in my sample code) 2. Finding features inside this polygon. 3. After finding these features, zooms to one of the feature, but zooms to the virtual world where selected polygon is.
Also, as Edgar stated, you will have to do the transformation youself to determine if a feature is in the vitual world and zoom to it accordingly. I have something called a WrapDatelineProjection class that does these transformations for me, which is especially important when clicking on the virtual world. I can share some aspects of the class with you if you want.
Thanks for helping on this Klaus, you are right, the transformation is needed. And one more thing, if the projection is used in this case, the transformation would be very complicated, e.g. in this case, the map unit is Meter, a polygon from trckOverlay lies across the dateline, RectangleShape(0, 1000000, 20137508, -1000000), then it should be converted to decimal degree to execute the spatial query, but the projection cannot convert the coordinates which is out of range, so we have to make it to (0, 1000000, 20037508, -1000000) in our code, and the converted result is (0,8.94657,179.99999,-8.94657), it's very closed to the 180 longitude but never reach. So please notice this when you are doing the transformation.
Now, I also have another class called OffsetProjects to render lines and polygons properly across the dateline. I doubt it will help for your current problem.
I think this forum prevents viewing .cs files. Can you please attach WrapDatelineProjection.cs as a text document? I’ll appreciate if you attach OffsetProjection class too, just in case.
I already using projection to transform my map from decimal degrees to meters (Mercator), and I cannot use WrapDatelineProjection in addition to the Mercator projection. I was looking for a simplest way to handle dateline wrapping transformation, but I guess I’ll have to do it manually for each feature.