iphone多边形显示数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iphone多边形显示数相关的知识,希望对你有一定的参考价值。
参考技术A 我正在尝试在ArcGIS地图上绘制多边形对象,但这些对象没有以正确的形状和正确的位置显示/绘制。在苹果地图上,多边形绘制为正方形,但在ArcGIS iPhone地图上,多边形显示为“无限线条”。我已附加了ArcGIS地图和苹果地图的输出我的代码
- (void)viewDidLoad
[super viewDidLoad];
NSURL* url = [NSURLURLWithString:@"https://gis.zoetermeer.nl/arcgis/rest/services/Public/GBKZ_Prod/MapServer/"];
AGSTiledMapServiceLayer *tiledLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:url];
tiledLayer.delegate = self;
[self.mapView addMapLayer:tiledLayer withName:@"Basemap Tiled Layer"];
- (void)layerDidLoad: (AGSLayer*) layer
NSLog(@"Layer added successfully");
AGSGraphicsLayer* myGraphicsLayer = [AGSGraphicsLayer graphicsLayer];
[self.mapView addMapLayer:myGraphicsLayer withName:@"Graphics Layer"];
NSLog(@"%i",myGraphicsLayer.spatialReferenceStatusValid);
AGSSpatialReference *specailRefference = [AGSSpatialReference spatialReferenceWithWKID: 28992];
NSString *coordinateString = @"4.4998839821275 52.066336122032, 4.499855 52.066286, 4.499792 52.066176, 4.499696 52.066014, 4.499631 52.066002, 4.499611 52.065966, 4.499604 52.065862, 4.499448 52.065609, 4.499412 52.065552, 4.499407 52.065543, 4.499399 52.065536, 4.499389 52.065529, 4.499378 52.065524, 4.4993733686962 52.065522931238, 4.4993733686962 52.066336122032";
NSString *coordinateString2 = @"4.4991002778594 52.065436800426, 4.499085 52.065422, 4.499100 52.065386, 4.499177 52.065316, 4.499370 52.065273, 4.499362 52.065259, 4.499053 52.065327, 4.498905 52.065360, 4.498794 52.065385, 4.498657 52.065415, 4.498647 52.065418, 4.498638 52.065423, 4.498632 52.065429, 4.498629 52.065436, 4.498629 52.065436800426";
NSString *coordinateString3 = @"4.4993733686962 52.075329338091, 4.5008878063918 52.075329338091, 4.5008878063918 52.074430016486, 4.4993733686962 52.074430016486";
AGSMutablePolygon *polyGon1 = [self getpolygon:coordinateString];
AGSMutablePolygon *polyGon2 = [self getpolygon:coordinateString2];
AGSMutablePolygon *polyGon3 = [self getpolygon:coordinateString3];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(52.066002,4.499631);
AGSPoint* gpsPoint = [[AGSPoint alloc] initWithX:coordinate.longitude
y:coordinate.latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]];
AGSGeometryEngine* engine = [AGSGeometryEngine defaultGeometryEngine];
AGSPoint* mapPoint = (AGSPoint*) [engine projectGeometry:gpsPoint toSpatialReference:specailRefference];
[self.mapView zoomToGeometry:mapPoint withPadding:100 animated:YES];
AGSGraphic *graphic1 = [[AGSGraphic alloc] initWithGeometry:polyGon1 symbol:[self barrierSymbol] attributes:nil];
[myGraphicsLayer addGraphic:graphic1];
AGSGraphic *graphic2 = [[AGSGraphic alloc] initWithGeometry:polyGon2 symbol:[self barrierSymbol] attributes:nil];
[myGraphicsLayer addGraphic:graphic2];
AGSGraphic *graphic3 = [[AGSGraphic alloc] initWithGeometry:polyGon3 symbol:[self barrierSymbol] attributes:nil];
[myGraphicsLayer addGraphic:graphic3];
- (AGSCompositeSymbol*)barrierSymbol
AGSCompositeSymbol *cs = [AGSCompositeSymbol compositeSymbol];
AGSSimpleLineSymbol *sls = [AGSSimpleLineSymbol simpleLineSymbol];
sls.color = [UIColor greenColor];
sls.style = AGSSimpleLineSymbolStyleSolid;
sls.width = 20;
AGSSimpleFillSymbol *sfs = [AGSSimpleFillSymbol simpleFillSymbol];
sfs.outline = sls;
sfs.style = AGSSimpleFillSymbolStyleHorizontal;
sfs.color = [UIColor darkTextColor];
[cs addSymbol:sfs];
return cs;
- (AGSMutablePolygon*)getpolygon:(NSString*)coordinateString
AGSSpatialReference *specailRefference = [AGSSpatialReference spatialReferenceWithWKID: 28992];
AGSMutablePolygon *polyGon = [[AGSMutablePolygon alloc] initWithSpatialReference:specailRefference];
[polyGon addRingToPolygon];
NSArray *tokens = [coordinateString componentsSeparatedByString:@","];
for (int k=0; k<[tokens count]; k++)
NSString *latlong = [tokens objectAtIndex:k];
NSArray *latlongArray = [latlong componentsSeparatedByString:@" "];
NSString *longi = [latlongArray objectAtIndex:0];
double longVal = [longi doubleValue];
NSString *lati = [latlongArray objectAtIndex:1];
double latVal = [lati doubleValue];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latVal, longVal);
AGSPoint* gpsPoint = [[AGSPoint alloc] initWithX:coordinate.longitude y:coordinate.latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]];
AGSGeometryEngine* engine = [AGSGeometryEngine defaultGeometryEngine];
AGSPoint* mapPoint = (AGSPoint*) [engine projectGeometry:gpsPoint toSpatialReference:specailRefference];
[polyGon addPointToRing:mapPoint];
return polyGon;
复制
请指导我如何正确地在ArcGIS地图上绘制多边形。谢谢!!
以二进制表示的交叉数/绕组数多边形测试(Python)
【中文标题】以二进制表示的交叉数/绕组数多边形测试(Python)【英文标题】:Crossing number/Winding number polygon test expressed as binary (Python) 【发布时间】:2015-06-21 14:24:38 【问题描述】:我正在尝试实现绕组数或交叉数测试,主要围绕布尔运算构建。 布尔值的要求是由于底层数据集的方法和效率,使得将变量委托给除布尔值以外的计数是次优的。
交叉数似乎最容易实现(我认为),因为它本质上是二进制的(偶数 (0) 与奇数 (1)),其中每一侧的交叉数测试的结果可以是 xor
-ed使用前面的结果,例如下面给出的代码,其中xyz
是我们评估的坐标。代码最后改编自http://geomalgorithms.com/a03-_inclusion.html。
#Original points:
pts=[[100,100],[200,200],[300,100],[400,300],[300,400],[200,300],[100,100]]
#Extremas:
min=[pts[0][0],pts[0][1]]
max=[pts[0][0],pts[0][1]]
for i in pts:
for j in range(2):
if i[j]<min[j]:
min[j]=i[j]
if i[j]>max[j]:
max[j]=i[j]
#New dimensions:
w=max[0]-min[0]
h=max[1]-min[1]
if len(sys.argv) > 2:
xyz=[int(sys.argv[1]),int(sys.argv[2])]
else:
xyz=[200,100]
#Normalize by cutting off lower than minimum, higher than maximum:
for i,p in enumerate(pts):
pts[i]=[p[0]-min[0],p[1]-min[1]]
x=0
y=1
logic=None
counting=0
for i in range(len(pts)-1):
test=( ( (pts[i][y] <= xyz[y]) and (pts[i+1][y] > xyz[y]) ) or \
( (pts[i][y] > xyz[y]) and (pts[i+1][y] <= xyz[y]) ) ) and \
(xyz[x] < pts[i][x] + ( (xyz[y]-pts[i][y])/(pts[i+1][y]-pts[i][y]) ) * (pts[i+1][x] - pts[i][x]))
if logic is None:
logic=test
else:
logic^=test
if test:
counting+=1
print logic
print counting
结果: 对于整个图像,二进制流会导致这些图像中的每个正方形都是一个步骤。 显然有些不对劲,但我似乎无法弄清楚为什么它在绕过右下角后变得混乱......有什么想法吗?
【问题讨论】:
【参考方案1】:啊哈!
&
!==and
和 |
!==or
。通过更改操作符,它起作用了。
【讨论】:
以上是关于iphone多边形显示数的主要内容,如果未能解决你的问题,请参考以下文章