使用iOS&;格达尔
我已经为iOS编译了GDAL1.11.0。我可以列出所有驱动程序,但如果我打开一个已知的地理参考PDF,我会得到一个错误4。。。未被识别为受支持的文件格式。我正在尝试使用geoPDF文件开发一个映射应用程序。这是我的密码使用iOS&;格达尔,ios,gdal,Ios,Gdal,我已经为iOS编译了GDAL1.11.0。我可以列出所有驱动程序,但如果我打开一个已知的地理参考PDF,我会得到一个错误4。。。未被识别为受支持的文件格式。我正在尝试使用geoPDF文件开发一个映射应用程序。这是我的密码 -(void)gdalTests { NSLog(@"GDAL Testing"); GDALAllRegister(); int a = GDALGetDriverCount(); for (int b=1; b<a; b++) {
-(void)gdalTests
{
NSLog(@"GDAL Testing");
GDALAllRegister();
int a = GDALGetDriverCount();
for (int b=1; b<a; b++) {
NSLog(@"GDAL Driver (%d) %s",b,GDALGetDriverLongName(GDALGetDriver(b)));
if (b==95) {
GDALDriverH drv = GDALGetDriver(b);
GDALRegisterDriver(drv);
NSLog(@"PDF DRIVER REGISTERED");
}
}
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"9030-4N KURRAJONG" ofType:@"pdf"];
GDALDatasetH dataset = GDALOpen ([filePath cStringUsingEncoding:[NSString defaultCStringEncoding]], GA_ReadOnly);
}
我通过使用
以下是用于访问文档数据的代码。我希望这对你有帮助
NSString *documentName = @"9030-4N KURRAJONG";
NSString *filePath = [[NSBundle mainBundle]pathForResource:documentName ofType:@"pdf"];
NSURL *documentUrl = [NSURL fileURLWithPath:filePath];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)documentUrl);
CGPDFStringRef string;
CGPDFDictionaryRef infoDict;
infoDict = CGPDFDocumentGetInfo(document);
NSDictionary *d = YLGetDictionaryFromCGPDFDictionary(infoDict);
NSLog(@"DOCUMENT INFO %@",d);
CGPDFPageRef page = CGPDFDocumentGetPage(document, 1);
NSLog(@"#rekt: %@",NSStringFromCGRect(CGPDFPageGetBoxRect(page, kCGPDFMediaBox)));
CGPDFDictionaryRef firstPage = CGPDFPageGetDictionary(page);
d = YLGetDictionaryFromCGPDFDictionary(firstPage);
NSArray *viewPortArray = [d objectForKey:@"VP"];
for (NSDictionary *d in viewPortArray) {
NSString *name = [d objectForKey:@"Name"];
NSLog(@"---- %@",name);
NSLog(@"%@",d);
}
for (int x = 0; x<5; x++) {
CGRect box = CGPDFPageGetBoxRect(page, x);
NSLog(@"PDF BOX %d = %0.4f %0.4f %0.4f %0.4f",x,box.origin.x,box.origin.y,box.size.width,box.size.height);
}
NSString*documentName=@“9030-4N KURRAJONG”;
NSString*文件路径=[[NSBundle mainBundle]路径用于资源:文档类型名称:@“pdf”];
NSURL*documentUrl=[NSURL fileURLWithPath:filePath];
CGPDFDocumentRef document=CGPDFDocumentCreateWithURL((CFURLRef)documentUrl);
CGPDFStringRef字符串;
cgpdfdictionarefinfodict;
infoDict=CGPDFDocumentGetInfo(文档);
NSDictionary*d=YLGetDictionaryFromCGPDFDictionary(infoDict);
NSLog(@“文件信息%@”,d);
CGPDFPageRef page=CGPDFDocumentGetPage(文档,1);
NSLog(@“#rekt:%@”,NSStringFromCGRect(CGPDFPageGetBoxRect(第页,kCGPDFMediaBox));
CGPDFDictionaryRef firstPage=CGPDFPageGetDictionary(第页);
d=YLGetDictionaryFromCGPDFDictionary(第一页);
NSArray*viewPortArray=[d objectForKey:@“VP”];
用于(viewPortArray中的NSDictionary*d){
NSString*name=[d objectForKey:@“name”];
NSLog(@“---%@”,名称);
NSLog(@“%@”,d);
}
对于(int x=0;xDid)你有没有发现这个问题?尝试做类似的事情。没有,很抱歉无法直接使用GDAL库破解它。我使用了。我将发布我使用的代码。非常有用!我今晚将尝试这个。你能访问地理数据吗?
NSString *documentName = @"9030-4N KURRAJONG";
NSString *filePath = [[NSBundle mainBundle]pathForResource:documentName ofType:@"pdf"];
NSURL *documentUrl = [NSURL fileURLWithPath:filePath];
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)documentUrl);
CGPDFStringRef string;
CGPDFDictionaryRef infoDict;
infoDict = CGPDFDocumentGetInfo(document);
NSDictionary *d = YLGetDictionaryFromCGPDFDictionary(infoDict);
NSLog(@"DOCUMENT INFO %@",d);
CGPDFPageRef page = CGPDFDocumentGetPage(document, 1);
NSLog(@"#rekt: %@",NSStringFromCGRect(CGPDFPageGetBoxRect(page, kCGPDFMediaBox)));
CGPDFDictionaryRef firstPage = CGPDFPageGetDictionary(page);
d = YLGetDictionaryFromCGPDFDictionary(firstPage);
NSArray *viewPortArray = [d objectForKey:@"VP"];
for (NSDictionary *d in viewPortArray) {
NSString *name = [d objectForKey:@"Name"];
NSLog(@"---- %@",name);
NSLog(@"%@",d);
}
for (int x = 0; x<5; x++) {
CGRect box = CGPDFPageGetBoxRect(page, x);
NSLog(@"PDF BOX %d = %0.4f %0.4f %0.4f %0.4f",x,box.origin.x,box.origin.y,box.size.width,box.size.height);
}