From 61a58f40267ee3d83a5c8135261cd0b3cab8ff55 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 9 Oct 2010 17:13:37 +0000 Subject: =?UTF-8?q?=E2=80=A2=20for=20each=20export/copy/drag=20method=20ot?= =?UTF-8?q?her=20than=20SQL=20pass=20any=20spatial=20fields=20as=20WKT=20s?= =?UTF-8?q?tring;=20for=20SQL=20pass=20them=20as=20X'=E2=80=A6'=20binary?= =?UTF-8?q?=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPCSVExporter.m | 5 ++++- Source/SPCopyTable.m | 14 ++++++++++++++ Source/SPSQLExporter.m | 6 +++++- Source/SPXMLExporter.m | 3 +++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Source/SPCSVExporter.m b/Source/SPCSVExporter.m index deae305b..132d181b 100644 --- a/Source/SPCSVExporter.m +++ b/Source/SPCSVExporter.m @@ -285,7 +285,10 @@ [csvCellString setString:[NSString stringWithString:dataConversionString]]; [dataConversionString release]; - } + } + else if ([csvCell isKindOfClass:[MCPGeometryData class]]) { + [csvCellString setString:[csvCell wktString]]; + } else { [csvCellString setString:[csvCell description]]; } diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 736052dc..886fe1e8 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -301,6 +301,9 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; [result appendFormat:@"%@\t", displayString]; [displayString release]; } + } + else if ([cellData isKindOfClass:[MCPGeometryData class]]) { + [result appendFormat:@"%@\t", [cellData wktString]]; } else [result appendFormat:@"%@\t", [cellData description]]; } else { @@ -374,6 +377,10 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; else if ([t isEqualToString:@"blobdata"] || [t isEqualToString:@"textdata"]) columnTypes[c] = 2; + // GEOMETRY data + else if ([t isEqualToString:@"geometry"]) + columnTypes[c] = 3; + // Default to strings else columnTypes[c] = 1; @@ -440,6 +447,10 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; } break; + // GEOMETRY + case 3: + [value appendFormat:@"X'%@', ", [mySQLConnection prepareBinaryData:[cellData data]]]; + break; // Unhandled cases - abort default: NSBeep(); @@ -540,6 +551,9 @@ NSInteger MENU_EDIT_COPY_AS_SQL = 2003; [result appendString:displayString]; [displayString release]; } + } + else if ([cellData isKindOfClass:[MCPGeometryData class]]) { + [result appendFormat:@"%@\t", [cellData wktString]]; } else [result appendFormat:@"%@\t", [cellData description]]; } else { diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index becccab2..64251456 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -385,7 +385,7 @@ else if ([object isKindOfClass:[NSData class]]) { if ([self sqlOutputEncodeBLOBasHex]) { - [sqlString appendFormat:@"X'%@", [connection prepareBinaryData:object]]; + [sqlString appendFormat:@"X'%@'", [connection prepareBinaryData:object]]; } else { [sqlString appendString:@"'"]; @@ -403,6 +403,10 @@ [sqlString appendString:@"'"]; } + // GEOMETRY data types directly as hex data + else if ([object isKindOfClass:[MCPGeometryData class]]) { + [sqlString appendFormat:@"X'%@'", [connection prepareBinaryData:[object data]]]; + } else { [cellValue setString:[object description]]; diff --git a/Source/SPXMLExporter.m b/Source/SPXMLExporter.m index 83497ec4..4d776f55 100644 --- a/Source/SPXMLExporter.m +++ b/Source/SPXMLExporter.m @@ -195,6 +195,9 @@ else if ([data isKindOfClass:[NSNull class]]) { [xmlItem setString:[self xmlNULLString]]; } + else if ([data isKindOfClass:[MCPGeometryData class]]) { + [xmlItem setString:[data wktString]]; + } else { [xmlItem setString:[data description]]; } -- cgit v1.2.3