From 933bb6c9254ba4761eb960c1b3893a9e57c39fb6 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 7 Oct 2010 22:23:29 +0000 Subject: =?UTF-8?q?=E2=80=A2=20enhanced=20spatial=20support=20-=20implemen?= =?UTF-8?q?ted=20native=20routine=20to=20immediate=20AsText()=20[MULTIPOLY?= =?UTF-8?q?GON=20and=20GEOMETRYCOLLECTION=20are=20not=20yet=20ready]=20-?= =?UTF-8?q?=20enabled=20editing=20of=20spatial=20data=20in=20Content=20Vie?= =?UTF-8?q?w=20for=20tables=20and=20views=20and=20in=20Custom=20Query=20vi?= =?UTF-8?q?a=20wkt=20strings=20which=20will=20be=20saved=20automatically?= =?UTF-8?q?=20as=20wkb=20by=20using=20GeomFromText()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPCustomQuery.m | 7 ++++++- Source/SPTableContent.m | 15 ++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'Source') diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 44ba5987..a945a53d 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -1752,6 +1752,9 @@ else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) { [fieldIDQueryStr appendFormat:@"%@=%@ AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]]; } + else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) { + [fieldIDQueryStr appendFormat:@"%@=X'%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareBinaryData:[aValue data]]]; + } else { [fieldIDQueryStr appendFormat:@"%@='%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareString:aValue]]; } @@ -1848,7 +1851,7 @@ return [prefs objectForKey:SPNullValue]; if ([theValue isKindOfClass:[MCPGeometryData class]]) - return [theValue description]; + return [theValue wktString]; return theValue; } @@ -1902,6 +1905,8 @@ newObject = @"CURRENT_TIMESTAMP"; } else if([anObject isEqualToString:[prefs stringForKey:SPNullValue]]) { newObject = @"NULL"; + } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) { + newObject = [NSString stringWithFormat:@"GeomFromText('%@')", anObject]; } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"bit"]) { newObject = [NSString stringWithFormat:@"b'%@'", ((![[anObject description] length] || [[anObject description] isEqualToString:@"0"]) ? @"0" : [anObject description])]; } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"date"] diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index cc5eb6bd..fd8f1703 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -1547,6 +1547,9 @@ else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) { [fieldIDQueryStr appendFormat:@"%@=%@ AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]]; } + else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) { + [fieldIDQueryStr appendFormat:@"%@=X'%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareBinaryData:[aValue data]]]; + } else { [fieldIDQueryStr appendFormat:@"%@='%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareString:aValue]]; } @@ -2673,12 +2676,12 @@ if ([[[tableDataInstance columnWithName:NSArrayObjectAtIndex(keys, i)] objectForKey:@"type"] isEqualToString:@"BIT"]) { [value setString:[NSString stringWithFormat:@"b'%@'", [mySQLConnection prepareString:tempValue]]]; } + else if ([tempValue isKindOfClass:[MCPGeometryData class]]) { + [value setString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:[tempValue data]]]]; + } // BLOB/TEXT data else if ([tempValue isKindOfClass:[NSData class]]) { - if([tableDataInstance columnIsGeometry:NSArrayObjectAtIndex(keys, i)]) - [value setString:[NSString stringWithFormat:@"GeomFromText('%@')", [[[NSString alloc] initWithData:tempValue encoding:NSASCIIStringEncoding] autorelease]]]; - else - [value setString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:tempValue]]]; + [value setString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:tempValue]]]; } else [value setString:[NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:tempValue]]]; @@ -3401,7 +3404,7 @@ } if([theValue isKindOfClass:[MCPGeometryData class]]) - return [theValue description]; + return [theValue wktString]; if ([theValue isNSNull]) return [prefs objectForKey:SPNullValue]; @@ -3542,6 +3545,8 @@ newObject = @"CURRENT_TIMESTAMP"; } else if([anObject isEqualToString:[prefs stringForKey:SPNullValue]]) { newObject = @"NULL"; + } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) { + newObject = [NSString stringWithFormat:@"GeomFromText('%@')", anObject]; } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"bit"]) { newObject = [NSString stringWithFormat:@"b'%@'", ((![[anObject description] length] || [[anObject description] isEqualToString:@"0"]) ? @"0" : [anObject description])]; } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"date"] -- cgit v1.2.3