Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 58849a0a8fd61b31 To 7f691c1e017837c1
2014-01-02
| ||
00:33 |
Remove point_to_tile functionality - no longer required by spec, and broken.
Also add missing gpkgBinary.c file. check-in: 89cec81bcc user: bradh tags: trunk | |
2014-01-01
| ||
10:29 |
Expose gaiaFromGeoPackageGeometryBlob function and use it as a fallback if we can't parse as spatialite geometry.
Also adds test. check-in: 7f691c1e01 user: bradh tags: trunk | |
06:24 | Implement GeomFromGPB() and test cases. check-in: 58849a0a8f user: bradh tags: trunk | |
01:39 | Add geopackage output geometry support (AsGPB() SQL function), based on existing WKB output. check-in: d26839b4fd user: bradh tags: trunk | |
Changes to src/gaiageo/gg_wkb.c.
54 54 #else 55 55 #include "config.h" 56 56 #endif 57 57 58 58 #include <spatialite/sqlite.h> 59 59 60 60 #include <spatialite/gaiageo.h> 61 + 62 +#ifdef ENABLE_GEOPACKAGE 63 +#include <spatialite/geopackage.h> 64 +#endif 61 65 62 66 static void 63 67 ParseWkbPoint (gaiaGeomCollPtr geo) 64 68 { 65 69 /* decodes a POINT from WKB */ 66 70 double x; 67 71 double y; ................................................................................ 1074 1078 gaiaFromSpatiaLiteBlobWkb (const unsigned char *blob, unsigned int size) 1075 1079 { 1076 1080 /* decoding from SpatiaLite BLOB to GEOMETRY */ 1077 1081 int type; 1078 1082 int little_endian; 1079 1083 int endian_arch = gaiaEndianArch (); 1080 1084 gaiaGeomCollPtr geo = NULL; 1085 +#ifdef ENABLE_GEOPACKAGE 1086 + if (size < 24) 1087 + return NULL; /* cannot be spatialite or geopackage blob */ 1088 + if (*(blob + 0) != GAIA_MARK_START) 1089 + { 1090 + /* Try geopackage binary, since it is not a standard spatialite blob */ 1091 + return gaiaFromGeoPackageGeometryBlob(blob, size); 1092 + } 1093 + if (size < 45) 1094 + return NULL; /* cannot be an internal BLOB WKB geometry */ 1095 +#else 1081 1096 if (size < 45) 1082 1097 return NULL; /* cannot be an internal BLOB WKB geometry */ 1083 1098 if (*(blob + 0) != GAIA_MARK_START) 1084 1099 return NULL; /* failed to recognize START signature */ 1100 +#endif 1085 1101 if (*(blob + (size - 1)) != GAIA_MARK_END) 1086 1102 return NULL; /* failed to recognize END signature */ 1087 1103 if (*(blob + 38) != GAIA_MARK_MBR) 1088 1104 return NULL; /* failed to recognize MBR signature */ 1089 1105 if (*(blob + 1) == GAIA_LITTLE_ENDIAN) 1090 1106 little_endian = 1; 1091 1107 else if (*(blob + 1) == GAIA_BIG_ENDIAN)
Changes to src/headers/spatialite/geopackage.h.
59 59 #include "sqlite.h" 60 60 61 61 #ifdef __cplusplus 62 62 extern "C" 63 63 { 64 64 #endif 65 65 66 +#include <spatialite/gaiageo.h> 66 67 67 68 /* Internal geopackage SQL function implementation */ 68 69 GEOPACKAGE_DECLARE void fnct_gpkgCreateBaseTables (sqlite3_context * 69 70 context, int argc, 70 71 sqlite3_value ** argv); 71 72 GEOPACKAGE_DECLARE void fnct_gpkgCreateTilesTable (sqlite3_context * 72 73 context, int argc, ................................................................................ 121 122 context, int argc, 122 123 sqlite3_value ** argv); 123 124 GEOPACKAGE_DECLARE void fnct_ToGPB (sqlite3_context * context, int argc, 124 125 sqlite3_value ** argv); 125 126 GEOPACKAGE_DECLARE void fnct_GeomFromGPB (sqlite3_context * context, 126 127 int argc, 127 128 sqlite3_value ** argv); 129 + 130 + GEOPACKAGE_DECLARE gaiaGeomCollPtr gaiaFromGeoPackageGeometryBlob (const unsigned char *gpb, 131 + unsigned int gpb_len); 128 132 129 133 /* Markers for unused arguments / variable */ 130 134 #if __GNUC__ 131 135 #define UNUSED __attribute__ ((__unused__)) 132 136 #else 133 137 #define UNUSED 134 138 #endif 135 139 136 140 #ifdef __cplusplus 137 141 } 138 142 #endif 139 143 140 144 #endif
Added test/sql_stmt_geopackage_tests/implicitgeopackagebinary1.testcase.
1 +implicit geopackage binary 1 2 +:memory: #use in-memory database 3 +SELECT Hex(CastToLineString(AsGPB(GeomFromText("LINESTRING(136 -35, 134 -33, 135 -32)", 4326)))) 4 +1 # rows (not including the header row) 5 +1 # columns 6 +Hex(CastToLineString(AsGPB(GeomFromText("LINESTRING(136 -35, 134 -33, 135 -32)", 4326)))) 7 +0001E61000000000000000C0604000000000008041C0000000000000614000000000000040C07C0200000003000000000000000000614000000000008041C00000000000C0604000000000008040C00000000000E0604000000000000040C0FE