Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert geojson to mysql_shape column type #28

Open
dacresni opened this issue Oct 23, 2019 · 1 comment
Open

convert geojson to mysql_shape column type #28

dacresni opened this issue Oct 23, 2019 · 1 comment
Labels
database enhancement New feature or request

Comments

@dacresni
Copy link
Collaborator

then use st_centroid to calculate centre after

@dacresni dacresni added the enhancement New feature or request label Oct 23, 2019
@jigglepuff jigglepuff assigned jigglepuff and unassigned jigglepuff Oct 30, 2019
@daniellovett
Copy link

daniellovett commented Oct 30, 2019

Working on this. Here's my SQL:

UPDATE parcels_geojson
SET temp1 = coordinates;

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, '], [', '||');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, '[[[[', 'MULTIPOLYGON(((');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, ']]]]', ')))');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, ', ', ' ');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, '||', ',');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, '[[', '((');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, ']]', '))');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, '],[', '),(');

UPDATE parcels_geojson
SET temp1 = REPLACE(temp1, '[]', NULL)
WHERE temp1 = '[]';

// needed to add first point again at the end
UPDATE parcels_geojson
SET temp2 = CONCAT(SUBSTRING(temp1, 16, 36),')))');

UPDATE parcels_geojson
SET temp1 = REPLACE(')))', temp2);

UPDATE parcels_geojson
SET multi_poly = ST_GeomFromText(temp1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants