diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-10-09 23:16:37 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-10-09 23:16:37 +0000 |
commit | 31a31c1fb9d46e9c6db1c836e03314b0b534194c (patch) | |
tree | 044edba373b899fc2dda03eb58aa6e1b6c966d79 /Source/SPStringAdditions.m | |
parent | a4ae7f6898d3b978938869382667a83535c1a805 (diff) | |
download | sequelpro-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 'Source/SPStringAdditions.m')
-rw-r--r-- | Source/SPStringAdditions.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index 2eafb4e9..a8695dbb 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -375,6 +375,33 @@ } /** + * Create the GeomFromText() string according to a possible SRID value + */ +- (NSString*)getGeomFromTextFromString +{ + + NSString *geomStr = [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + if(![self rangeOfString:@")"].length || [self length] < 5) return @""; + + // No SRID + if([geomStr hasSuffix:@")"]) + return [NSString stringWithFormat:@"GeomFromText('%@')", geomStr]; + // Has SRID + else { + NSUInteger idx = [geomStr length]-1; + while(idx>1) { + if([geomStr characterAtIndex:idx] == ')') + break; + idx--; + } + return [NSString stringWithFormat:@"GeomFromText('%@'%@)", + [geomStr substringToIndex:idx+1], [geomStr substringFromIndex:idx+1]]; + } + +} + +/** * Returns the minimum of a, b and c. */ - (NSInteger)smallestOf:(NSInteger)a andOf:(NSInteger)b andOf:(NSInteger)c |