小编Jer*_*oen的帖子

如何在MKOverlayView上显示图像?

更新:

使用MKOverlayView投影在MKMapView上的图像使用墨卡托投影,而我用作输入数据的图像使用WGS84投影.有没有办法将输入图像转换为正确的投影WGS84 - >墨卡托,没有平铺图像,可以在运行中完成吗?

通常,您可以使用程序gdal2tiles将图像转换为右投影.然而,输入数据每十五分钟改变一次,因此图像必须每十五分钟转换一次.所以转换必须在飞行中完成.我也想平铺由Mapkit完成,而不是通过使用gdal2tiles或GDAL框架自己.

更新结束

我目前正在开展一个项目,在世界某些地方展示降雨雷达.雷达图像是由欧洲气象卫星应用组织提供的,他们提供可以被加载到谷歌地球或谷歌地图KML文件.如果我加载在谷歌地图的KML文件,它显示完美,但如果我画上的MKMapView使用MKOverlayView的图像时,图像略微的.

例如,在左侧,Google地图和右侧,相同的图像显示在MKMapView上.

替代文字

替代文字

该图像覆盖可以被看作表面谷歌地图,即用于图像的卫星是"气象卫星0度"卫星.

这两个图像覆盖面大小是一样的,这是从KML文件LatLonBox,它指定了顶部,底部,右侧和左侧地面叠加的边界框的两侧对齐.

  <LatLonBox id="GE_MET0D_VP-MPE-latlonbox">
        <north>57.4922</north>
        <south>-57.4922</south>
        <east>57.4922</east>
        <west>-57.4922</west>
        <rotation>0</rotation>
  </LatLonBox>
Run Code Online (Sandbox Code Playgroud)

我用这些参数创建了一个名为RadarOverlay的新自定义MKOverlay对象,

[[RadarOverlay alloc] initWithImageData:[[self.currentRadarData objectAtIndex:0] valueForKey:@"Image"] withLowerLeftCoordinate:CLLocationCoordinate2DMake(-57.4922, -57.4922) withUpperRightCoordinate:CLLocationCoordinate2DMake(57.4922, 57.4922)];
Run Code Online (Sandbox Code Playgroud)

自定义MKOverlay对象的实现; RadarOverlay

- (id) initWithImageData:(NSData*) imageData withLowerLeftCoordinate:(CLLocationCoordinate2D)lowerLeftCoordinate withUpperRightCoordinate:(CLLocationCoordinate2D)upperRightCoordinate
{
     self.radarData = imageData;

     MKMapPoint lowerLeft = MKMapPointForCoordinate(lowerLeftCoordinate);
     MKMapPoint upperRight = MKMapPointForCoordinate(upperRightCoordinate);

     mapRect = MKMapRectMake(lowerLeft.x, upperRight.y, upperRight.x - lowerLeft.x, lowerLeft.y - upperRight.y);

     return self;
}

- (CLLocationCoordinate2D)coordinate
{
     return MKCoordinateForMapPoint(MKMapPointMake(MKMapRectGetMidX(mapRect), MKMapRectGetMidY(mapRect)));
}

- (MKMapRect)boundingMapRect
{
     return mapRect;
} …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch core-graphics objective-c mapkit

15
推荐指数
2
解决办法
1万
查看次数

性能:Quartz2D与OpenGL ES(GLKit)

我正在开发一个项目,您可以使用触摸在屏幕上绘图.我想过使用OpenGL,但是我遇到了两个例子; 一个使用OpenGL,另一个使用Quartz2D.

来自Apple,GLPaint的示例项目,使用OpenGL

使用Quartz2D从EffectiveUI的示例项目

让我感到震惊的是,Quartz实现比OpenGL实现要快得多.我一直认为OpenGL会更快,因为它的级别较低,几乎可以与硬件本身对话.我知道Quartz2D也在使用OpenGL绘图,所以我的问题是; 为什么GLPaint示例中的绘图如此之慢?

你能对GLPaint项目进行任何有利于性能的优化吗?

iphone opengl-es ios glkit

5
推荐指数
1
解决办法
1863
查看次数