Map Bounding Box NE and SW, get NW and SE

I have two CLLocationCoordinate2D that represent a visible coordinate region/box on a map. They are the NE corner and the SW corner.

CLLocationCoordinate2D neCoordinate = self.mapboxMapView.visibleCoordinateBounds.ne;
CLLocationCoordinate2D swCoordinate = self.mapboxMapView.visibleCoordinateBounds.sw;

How can I mathematically convert those two coordinates to find the NW and SE coordinates/corners?

1 answer

  • answered 2018-07-10 23:11 gadu

    Can't you just pull out the equivalent points from each coordinate and combine them your own way?

    neCoordinate.latitude (east) and swCoordinate.longitude (south) to make the SECoordinate?

    neCoordinate.longitude (north) and swCoordinate.latitude (west) to make NWCoordinate?

    aka:

    CLLocationCoordinate2D seCoordinate = CLLocationCoordinate2DMake(latitude: neCoordinate.latitude, longitude: swCoordinate.longitude);
    CLLocationCoordinate2D nwCoordinate = CLLocationCoordinate2DMake(latitude: swCoordinate.latitude, longitude: neCoordinate.longitude);