aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-10-09 23:16:37 +0000
committerBibiko <bibiko@eva.mpg.de>2010-10-09 23:16:37 +0000
commit31a31c1fb9d46e9c6db1c836e03314b0b534194c (patch)
tree044edba373b899fc2dda03eb58aa6e1b6c966d79 /Frameworks/MCPKit/MCPFoundationKit
parenta4ae7f6898d3b978938869382667a83535c1a805 (diff)
downloadsequelpro-31a31c1fb9d46e9c6db1c836e03314b0b534194c.tar.gz
sequelpro-31a31c1fb9d46e9c6db1c836e03314b0b534194c.tar.bz2
sequelpro-31a31c1fb9d46e9c6db1c836e03314b0b534194c.zip
• enabled SRID editing of spatial fields via WKT string
- the SRID value will be appended at the WKT string like POINT(1 1),101 which will be transformed to GeomFromText('POINT(1 1)',101) on the fly - otherwise the SRID information will be deleted after editing a geometry field
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m33
1 files changed, 21 insertions, 12 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m b/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m
index cdb13348..f8c1bbf6 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPGeometryData.m
@@ -24,12 +24,11 @@
#import "MCPGeometryData.h"
-
#define SIZEOF_STORED_UINT32 4
#define SIZEOF_STORED_DOUBLE 8
#define POINT_DATA_SIZE (SIZEOF_STORED_DOUBLE*2)
#define WKB_HEADER_SIZE (1+SIZEOF_STORED_UINT32)
-#define BUFFER_START 4
+#define BUFFER_START 0
@implementation MCPGeometryData
@@ -103,9 +102,8 @@
*/
- (NSString*)wktString
{
-
char byteOrder;
- UInt32 geoType, numberOfItems, numberOfSubItems, numberOfSubSubItems, numberOfCollectionItems;
+ UInt32 geoType, srid, numberOfItems, numberOfSubItems, numberOfSubSubItems, numberOfCollectionItems;
st_point_2d aPoint;
NSUInteger i, j, k, n; // Loop counter for numberOf...Items
@@ -116,6 +114,9 @@
if (bufferLength < WKB_HEADER_SIZE)
return @"Header Error";
+ memcpy(&srid, &geoBuffer[0], SIZEOF_STORED_UINT32);
+ ptr += SIZEOF_STORED_UINT32;
+
byteOrder = geoBuffer[ptr];
if(byteOrder != 0x1)
@@ -129,7 +130,7 @@
case wkb_point:
memcpy(&aPoint, &geoBuffer[ptr], POINT_DATA_SIZE);
- return [NSString stringWithFormat:@"POINT(%.16g %.16g)", aPoint.x, aPoint.y];
+ return [NSString stringWithFormat:@"POINT(%.16g %.16g)%@", aPoint.x, aPoint.y, (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
break;
case wkb_linestring:
@@ -141,7 +142,7 @@
[wkt appendFormat:@"%.16g %.16g%@", aPoint.x, aPoint.y, (i < numberOfItems-1) ? @"," : @""];
ptr += POINT_DATA_SIZE;
}
- [wkt appendString:@")"];
+ [wkt appendFormat:@")%@", (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
return wkt;
break;
@@ -160,7 +161,7 @@
}
[wkt appendFormat:@")%@", (i < numberOfItems-1) ? @"," : @""];
}
- [wkt appendString:@")"];
+ [wkt appendFormat:@")%@", (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
return wkt;
break;
@@ -173,7 +174,7 @@
[wkt appendFormat:@"%.16g %.16g%@", aPoint.x, aPoint.y, (i < numberOfItems-1) ? @"," : @""];
ptr += POINT_DATA_SIZE+WKB_HEADER_SIZE;
}
- [wkt appendString:@")"];
+ [wkt appendFormat:@")%@", (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
return wkt;
break;
@@ -193,7 +194,7 @@
ptr += WKB_HEADER_SIZE;
[wkt appendFormat:@")%@", (i < numberOfItems-1) ? @"," : @""];
}
- [wkt appendString:@")"];
+ [wkt appendFormat:@")%@", (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
return wkt;
break;
@@ -219,7 +220,7 @@
ptr += WKB_HEADER_SIZE;
[wkt appendFormat:@")%@", (i < numberOfItems-1) ? @"," : @""];
}
- [wkt appendString:@")"];
+ [wkt appendFormat:@")%@", (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
return wkt;
break;
@@ -341,7 +342,7 @@
}
[wkt appendString:(n < numberOfCollectionItems-1) ? @"," : @""];
}
- [wkt appendString:@")"];
+ [wkt appendFormat:@")%@", (srid) ? [NSString stringWithFormat:@",%u",srid]: @""];
return wkt;
break;
@@ -361,7 +362,7 @@
{
char byteOrder;
- UInt32 geoType, numberOfItems, numberOfSubItems, numberOfSubSubItems, numberOfCollectionItems;
+ UInt32 geoType, srid, numberOfItems, numberOfSubItems, numberOfSubSubItems, numberOfCollectionItems;
st_point_2d aPoint;
NSUInteger i, j, k, n; // Loop counter for numberOf...Items
@@ -383,6 +384,9 @@
if (bufferLength < WKB_HEADER_SIZE)
return nil;
+ memcpy(&srid, &geoBuffer[0], SIZEOF_STORED_UINT32);
+ ptr += SIZEOF_STORED_UINT32;
+
byteOrder = geoBuffer[ptr];
if(byteOrder != 0x1)
@@ -409,6 +413,7 @@
[NSNumber numberWithDouble:y_max],
nil], @"bbox",
coordinates, @"coordinates",
+ [NSNumber numberWithUnsignedInt:srid], @"srid",
@"POINT", @"type",
nil];
break;
@@ -463,6 +468,7 @@
[NSNumber numberWithDouble:y_max],
nil], @"bbox",
coordinates, @"coordinates",
+ [NSNumber numberWithUnsignedInt:srid], @"srid",
@"POLYGON", @"type",
nil];
break;
@@ -487,6 +493,7 @@
[NSNumber numberWithDouble:y_max],
nil], @"bbox",
coordinates, @"coordinates",
+ [NSNumber numberWithUnsignedInt:srid], @"srid",
@"MULTIPOINT", @"type",
nil];
break;
@@ -518,6 +525,7 @@
[NSNumber numberWithDouble:y_max],
nil], @"bbox",
coordinates, @"coordinates",
+ [NSNumber numberWithUnsignedInt:srid], @"srid",
@"MULTILINESTRING", @"type",
nil];
break;
@@ -553,6 +561,7 @@
[NSNumber numberWithDouble:y_max],
nil], @"bbox",
coordinates, @"coordinates",
+ [NSNumber numberWithUnsignedInt:srid], @"srid",
@"MULTIPOLYGON", @"type",
nil];
break;