确定SouthWest和NorthEast的室内地图集平面图

时间:2016-09-12 08:43:21

标签: ios objective-c xcode google-maps-sdk-ios indoor-positioning-system

我正在尝试使用IndoorAtlas SDK构建一个用于室内导航的小例子。我使用的是谷歌地图而不是Apple地图。 一旦我从IndoorAtlas后端获取平面图图像,我需要创建GMSCoordinateBounds,它需要SouthWest和NorthEast坐标来创建边界。我需要知道如何正确地确定这些坐标。 目前我的代码看起来像这样:

CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(self.floorPlan.topRight.latitude,self.floorPlan.topRight.longitude);
CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(self.floorPlan.bottomLeft.latitude,self.floorPlan.bottomLeft.longitude);


GMSCoordinateBounds *overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:southWest coordinate:northEast];


UIImage *icon = fpImage;
GMSGroundOverlay *overlay =
[GMSGroundOverlay groundOverlayWithBounds:overlayBounds icon:icon];
overlay.bearing = self.floorPlan.bearing;
overlay.map = _mapView;

GMSCameraUpdate *updatedCamera = [GMSCameraUpdate setTarget:self.floorPlan.center zoom:10];
[self.mapView animateWithCameraUpdate:updatedCamera];
self.marker.position = self.camera.target;
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:self.camera];

如何确定上述坐标。尝试上面的坐标我得不到正确的矩形。

还有其他方法可以确定吗?

1 个答案:

答案 0 :(得分:1)

我找到了计算坐标的方法

- (NSArray *)calculateLongLatDegreesInMeters:(CLLocationDegrees)纬度 {

float lat = M_PI * latitude / 180;

// Constants for calculating lengths

float m1 = 111132.92;

float m2 = -559.82;

float m3 = 1.175;

float m4 = -0.0023;

float p1 = 111412.84;

float p2 = -93.5;

float p3 = 0.118;

float eq1 = m1 + (m2 * cos(2 * lat)) + (m3 * cos(4 * lat));

float latitudeDegreeInMeters = eq1 + (m4 * cos(6 * lat));

float longitudeDegreeInMeters = (p1 * cos(lat)) + (p2 * cos(3 * lat)) +    (p3 * cos(5 * lat));

NSString *latDegInMtr = [NSString stringWithFormat:@"%f",latitudeDegreeInMeters];
NSString *lonDegInMtr = [NSString stringWithFormat:@"%f",longitudeDegreeInMeters];


NSArray *arr = [NSArray arrayWithObjects:latDegInMtr,lonDegInMtr, nil];



return arr; //(latitudeDegreeInMeters, longitudeDegreeInMeters)

}