CONABIO / antares3

Madmex with open data cube and in python3
2 stars 2 forks source link

rewrite antares init cmd for double checking of already ingested shapefiles #61

Closed palmoreck closed 5 years ago

palmoreck commented 5 years ago

If a shapefile is already ingested then antares init -c command needs to check if shapefile is already present in table: madmex_region

Right now is not working this double-check:

select id,name,country_id,added from madmex_region;
id |        name         | country_id |             added
----+---------------------+------------+-------------------------------
  1 | Aguascalientes      |          1 | 2019-02-25 21:59:43.059378+00
  2 | Baja California Sur |          1 | 2019-02-25 21:59:43.962871+00
  3 | Baja California     |          1 | 2019-02-25 21:59:44.595236+00
  4 | Campeche            |          1 | 2019-02-25 21:59:45.051939+00
  5 | Chiapas             |          1 | 2019-02-25 21:59:45.450227+00
  6 | Chihuahua           |          1 | 2019-02-25 21:59:45.775253+00
  7 | Coahuila            |          1 | 2019-02-25 21:59:46.072472+00
  8 | Colima              |          1 | 2019-02-25 21:59:46.37985+00
  9 | Distrito Federal    |          1 | 2019-02-25 21:59:46.667378+00
...

32 | Zacatecas           |          1 | 2019-02-25 21:59:55.457838+00
 33 | Aguascalientes      |          1 | 2019-02-25 22:02:39.873441+00
 34 | Baja California Sur |          1 | 2019-02-25 22:02:40.765837+00
 35 | Baja California     |          1 | 2019-02-25 22:02:41.392092+00
 36 | Campeche            |          1 | 2019-02-25 22:02:41.855333+00
 37 | Chiapas             |          1 | 2019-02-25 22:02:42.250293+00
 38 | Chihuahua           |          1 | 2019-02-25 22:02:42.563685+00
 39 | Coahuila            |          1 | 2019-02-25 22:02:42.865023+00
...
64 | Zacatecas           |          1 | 2019-02-25 22:02:52.266696+00
 67 | Aguascalientes      |          1 | 2019-04-22 19:11:00.087324+00
 68 | Baja California Sur |          1 | 2019-04-22 19:11:00.836004+00
 69 | Baja California     |          1 | 2019-04-22 19:11:01.359579+00
 70 | Campeche            |          1 | 2019-04-22 19:11:01.719526+00
 71 | Chiapas             |          1 | 2019-04-22 19:11:02.010343+00
 72 | Chihuahua           |          1 | 2019-04-22 19:11:02.227548+00
 73 | Coahuila            |          1 | 2019-04-22 19:11:02.444947+00
...
98 | Zacatecas           |          1 | 2019-04-22 19:11:09.320285+00

And

select id,name from madmex_country;
 id | name
----+------
  1 | MEX
(1 row)
palmoreck commented 5 years ago

This was solved using unique in name for madmex_region table:

https://github.com/CONABIO/antares3/commit/67d984328b9a6e2ef3e7de4df2f001cb503493b8