Peter Johnson
|
--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spatialite-users/6c9e7076-efec-4a72-af54-6c06cdd18864%40googlegroups.com.
Error: no such function: json_object
gcc -g -shared json1.c -o json1.dll
sqlite> SELECT load_extension("json1");
Error: %1 is not a valid Win32 application.
To unsubscribe from this group and stop receiving emails from it, send an email to spatiali...@googlegroups.com.
I get the following error when I load the compiled extension:
sqlite> SELECT load_extension("json1");Error: %1 is not a valid Win32 application.
At this stage, I'm a bit blocked.If somebody notes something wrong on the step I followed, I'm interested about any feedback
Hi Sandro,
Thanks for the feedback. Indeed, I worked with a 64bits Sqlite3 and generated the 32bits Json extension.
Two things here
As I downloaded the 64bits mod_spatialite binaries version including Sqlite3, I generated a 64bits json extension using MSYS2 MinGW 64-bit. It’s worked well and I retrieve all the dll files for 64 bits (including json1.dll).
When I try to load json1.dll through Sqlite3 by executing
SELECT load_extension('json1');
64bits Sqlite3 shell suddenly closes without any warning or error message.
For testing purpose, I also downloaded the 32bits mod_spatialitebinaries and generated 32bits json extension. Trying to load this extension, I note the same behaviour (32bits Sqlite3 shell closes).
I did not succeed to solve this problem. Maybe do you know this problem.
Then, to test the solution proposed by Peter, I downloaded the bundleof 32 bits command-line tools from SQLite Home Page. Json1 extension is loaded by default and I can manage GeoJSON files from this shell.
I built upon the Peter’s proposal. The GeoJSON file I have is more complex given that it contains a Feature collection with many feature objects. The type of the spatial objects can be points, polylines or polygons as well as null geometry. I share here an example of GeoJson file. Each point/vertex have a Z value.
To store the spatial objects, I created 3 tables on my spatialite DB (one/geometry type). Then, I run the following INSERT INTO SQL statement (example for polyline. It must be adapt for points/polygon) using Json_tree table-valued function)
I
NSERT INTO
MYGEOMTABLE_LINE
(geom)
SELECT
GeomFromText
(
AsText(GeomFromGeoJson(
json_object('type',json_extract(value,'$.type'),'coordinates',json_extract(value,'$.coordinates')))
)
,
4326)
FROM
json_
tree
(
readfile('
PATH_TO_GEOJSON
\
test
.
geojson
')
)
WHERE
key ='geometry' and value is not NULL and value LIKE '%
Line
%'
Maybe it's not the most efficient way to import GeoJSON to Spatialite but It works like a charm. I’m going to go forward to build on it.
Thanks for your feedback