ISO GPS定位,坐标转换以及如何显示

本文介绍了一个名为GPScombineClass的公共类,该类用于实现GPS位置定位、坐标转换等功能,包括从手机GPS坐标到火星坐标,再到百度地图坐标的转换算法。同时,还提供了在地图上标注位置的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这个写的公共类叫做:GPScombineClass类主要展示GPS位置的定位,GPS坐标的获取,然后从手机坐标转换成火星坐标,继而在需要的情况下,由火星转百度 ,百度转火星的详细算法;


GPScombineClass.h


#import <Foundation/Foundation.h>

#import <CoreLocation/CoreLocation.h>

#import "CSqlite.h"

#import <MapKit/MapKit.h>

@interface GPScombineClass : NSObject<MKMapViewDelegate>{

    CLLocationManager *locationManager;

    CSqlite *m_sqlite;

    

    UILabel *m_locationName;

    MKMapView *mainMapView;

@public CLLocationCoordinate2D baidulocation;

    CLLocationCoordinate2D deleeverLocation;

}

-(void)OpenGPSmapView;

//在地图上放上自己的位置--外接接口

-(void)setMyMapPonitByMKMapView:(MKMapView *)MyMap;

@end

@interface POI : NSObject <MKAnnotation> {

    

    CLLocationCoordinate2D coordinate;

    NSString *subtitle;

    NSString *title;

}


@property (nonatomic,readonly) CLLocationCoordinate2D coordinate;

@property (nonatomic,retain) NSString *subtitle;

@property (nonatomic,retain) NSString *title;


-(id) initWithCoords:(CLLocationCoordinate2D) coords;


@end


GPScombineClass.m


#import "GPScombineClass.h"


const double x_pi = 3.14159265358979324 * 3000.0 / 180.0;

@implementation GPScombineClass

-(void)OpenGPSmapView{

    m_sqlite = [[CSqlite alloc]init];

    [m_sqlite openSqlite];

    if ([CLLocationManager locationServicesEnabled]) { // 检查定位服务是否可用

        locationManager = [[CLLocationManager alloc] init];

        locationManager.delegate = self;

        locationManager.distanceFilter=0.5;

        locationManager.desiredAccuracy = kCLLocationAccuracyBest;

        [locationManager startUpdatingLocation]; // 开始定位

    }

    

    NSLog(@"GPS 启动");

}


// 定位成功时调用

- (void)locationManager:(CLLocationManager *)manager

    didUpdateToLocation:(CLLocation *)newLocation

           fromLocation:(CLLocation *)oldLocation

{

    CLLocationCoordinate2D mylocation = newLocation.coordinate;//手机GPS

    

    mylocation = [self zzTransGPS:mylocation];///转换成火星GPS

    deleeverLocation=mylocation;

    baidulocation=[self hhTrans_bdGPS:mylocation];//转换成百度地图

     /*

    //显示火星坐标

    [self SetMapPoint:mylocation MKMapView:mainMapView];

   

    /////////获取位置信息

    CLGeocoder *geocoder = [[CLGeocoder alloc] init];

    [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray* placemarks,NSError *error)

     {

         if (placemarks.count >0   )

         {

             CLPlacemark * plmark = [placemarks objectAtIndex:0];

             

             NSString * country = plmark.country;

             NSString * city    = plmark.locality;

             

             

             NSLog(@"%@-%@-%@",country,city,plmark.name);

             self->m_locationName.text =plmark.name;

             NSLog(@"%@",self->m_locationName);

         }

         

         NSLog(@"%@",placemarks);

         

     }];

    

    //[geocoder release];

    */

}

// 定位失败时调用

- (void)locationManager:(CLLocationManager *)manager

       didFailWithError:(NSError *)error {

    NSLog(@"定位失败");

}


//把手机GPS坐标转换成火星坐标 google坐标)

-(CLLocationCoordinate2D)zzTransGPS:(CLLocationCoordinate2D)yGps

{

    int TenLat=0;

    int TenLog=0;

    TenLat = (int)(yGps.latitude*10);

    TenLog = (int)(yGps.longitude*10);

    NSString *sql = [[NSString alloc]initWithFormat:@"select offLat,offLog from gpsT where lat=%d and log = %d",TenLat,TenLog];

    NSLog(sql);

    sqlite3_stmt* stmtL = [m_sqlite NSRunSql:sql];

    int offLat=0;

    int offLog=0;

    while (sqlite3_step(stmtL)==SQLITE_ROW)

    {

        offLat = sqlite3_column_int(stmtL, 0);

        offLog = sqlite3_column_int(stmtL, 1);

        

    }

    

    yGps.latitude = yGps.latitude+offLat*0.0001;

    yGps.longitude = yGps.longitude + offLog*0.0001;

    return yGps;

    

    

}

//在地图上放上自己的位置--外接接口

-(void)setMyMapPonitByMKMapView:(MKMapView *)MyMap{

 //显示火星坐标

    [self SetMapPoint:deleeverLocation MKMapView:MyMap];

    MyMap=mainMapView;

}

//在地图上放上自己的位置

-(void)SetMapPoint:(CLLocationCoordinate2D)myLocation MKMapView:(MKMapView *)mapView

{

//    POI* m_poi = [[POI alloc]initWithCoords:myLocation];

//    

//    [mapView addAnnotation:m_poi];

    

    MKCoordinateRegion theRegion = { {0.0, 0.0 }, { 0.0, 0.0 } };

    theRegion.center=myLocation;

    [mapView setZoomEnabled:YES];

    [mapView setScrollEnabled:YES];

    theRegion.span.longitudeDelta = 0.01f;

    theRegion.span.latitudeDelta = 0.01f;

    [mapView setRegion:theRegion animated:YES];

    

}


//把火星坐标转换成百度坐标

-(CLLocationCoordinate2D)hhTrans_bdGPS:(CLLocationCoordinate2D)fireGps

{

    CLLocationCoordinate2D bdGps;

    double huo_x=fireGps.longitude;

    double huo_y=fireGps.latitude;

    double z = sqrt(huo_x * huo_x + huo_y * huo_y) + 0.00002 * sin(huo_y * x_pi);

    double theta = atan2(huo_y, huo_x) + 0.000003 * cos(huo_x * x_pi);

    bdGps.longitude = z * cos(theta) + 0.0065;

    bdGps.latitude = z * sin(theta) + 0.006;

    return bdGps;

}

#pragma mark 显示商品信息

#pragma mark

-(void)showPurchaseOnMapByLocation:(CLLocationCoordinate2D)baiduGPS MKMapView:(MKMapView *)myMapView{

    CLLocationCoordinate2D googleGPS;

    googleGPS=[self hhTrans_GCGPS:baiduGPS];//转换为百度

    [self SetPurchaseMapPoint:googleGPS MKMapView:myMapView];

}

//把百度地图转换成谷歌地图--火星坐标

-(CLLocationCoordinate2D)hhTrans_GCGPS:(CLLocationCoordinate2D)baiduGps

{

    CLLocationCoordinate2D googleGps;

    double bd_x=baiduGps.longitude - 0.0065;

    double bd_y=baiduGps.latitude - 0.006;

    double z = sqrt(bd_x * bd_x + bd_y * bd_y) - 0.00002 * sin(bd_y * x_pi);

    double theta = atan2(bd_y, bd_x) - 0.000003 * cos(bd_x * x_pi);

    googleGps.longitude = z * cos(theta);

    googleGps.latitude = z * sin(theta);

    return googleGps;

}


-(void)SetPurchaseMapPoint:(CLLocationCoordinate2D)myLocation MKMapView:(MKMapView *)mapView

{

    POI* m_poi = [[POI alloc]initWithCoords:myLocation];

    

    [mapView addAnnotation:m_poi];

    

    MKCoordinateRegion theRegion = { {0.0, 0.0 }, { 0.0, 0.0 } };

    theRegion.center=myLocation;

    [mapView setZoomEnabled:YES];

    [mapView setScrollEnabled:YES];

    theRegion.span.longitudeDelta = 0.01f;

    theRegion.span.latitudeDelta = 0.01f;

    [mapView setRegion:theRegion animated:YES];}


@end



<think>嗯,用户想在ArcGIS Pro中使用GPS定位点,我需要根据提供的引用资料来整理步骤。首先,引用[1]提到了数据处理,包括经纬度和时间戳处理,还有将数据导入ArcGIS Pro并导出成shp文件。这应该涉及到数据准备和导入的步骤。 接下来,引用[3]提到了链接图表的地理布局,可能和空间数据的使用有关。还有导出预设的部分,但用户的问题是关于GPS定位点操作,可能更多关注数据导入和显示。需要确认GPS数据格式,通常可能是CSV或者文本文件,包含经纬度信息。 步骤应该是:先处理原始数据,确保经纬度格式正确,比如转换为十进制度格式。然后导入到ArcGIS Pro中,可能需要使用“添加数据”功能或者地理处理工具中的“XY表转点”工具。之后进行坐标系统设置,确保和GPS数据一致,通常是WGS84。接着导出为shp文件,方便后续使用。 用户可能需要具体的操作指南,比如如何转换经纬度,如何导入,如何设置坐标系统。还要注意可能遇到的问题,比如格式错误或者坐标系统不匹配。此外,引用[2]提到ArcGIS Pro的教程资源,可能可以推荐用户查阅相关文库获取更详细步骤。 需要分步骤说明,从数据处理到导入,再到导出。可能还需要提到如何在地图上显示这些点,或者进行空间分析。不过根据引用内容,主要步骤应该是处理数据、导入、坐标设置和导出。确保每个步骤清晰,引用对应的参考资料。</think>以下是在ArcGIS Pro中使用GPS定位点的分步操作方法,整合了空间数据处理与坐标定位的核心技术流程: ### 一、数据预处理 1. **原始数据整理** - 确保GPS数据包含$纬度$、$经度$字段,建议采用十进制度格式(如:$121.4737°E,31.2304°N$) - 时间戳字段需转换ISO 8601标准格式:$$YYYY-MM-DDThh:mm:ssZ$$[^1] 2. **坐标系统验证** - 在Excel或文本编辑器中检查坐标值范围 - 纬度范围:$[-90°,90°]$ - 经度范围:$[-180°,180°]$ ### 二、数据导入流程 ```python # 示例代码:通过ArcPy实现批量导入 import arcpy input_table = "GPS_Data.csv" output_feature = "GPS_Points.shp" arcpy.management.XYTableToPoint( input_table, output_feature, "Longitude", "Latitude", coordinate_system=arcpy.SpatialReference(4326)) # WGS84坐标系 ``` 1. **可视化验证** - 在目录窗格右键点击新建要素类 → 选择「XY表转点」工具 - 设置坐标系时应与GPS设备采集参数保持一致(通常为WGS84)[^2] ### 三、空间数据操作 $$ 投影转换公式: x_{proj} = f(\phi,\lambda) \\ y_{proj} = g(\phi,\lambda) $$ 其中$(\phi,\lambda)$为地理坐标系下的经纬度值 1. **精度增强方法** - 叠加高分辨率底图进行位置校正 - 使用空间校正工具处理偏移问题 - 通过地理配准匹配历史影像数据[^3] ### 四、成果输出 - 导出预设配置时建议保持分辨率≥300dpi - 支持同时生成空间索引文件(.sbn)提升查询性能 - 属性表应包含原始GPS元数据字段
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值