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

Gazetteer model #3979

Open
wants to merge 270 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
270 commits
Select commit Hold shift + click to select a range
b34075a
#1954 Small refactorings and changes in GeographicItem
kleintom Jun 16, 2024
d7b5c8d
#1954 Begin changing `column` references to `shape` refs in Geographi…
kleintom Jun 17, 2024
8874fa0
#1954 Assume postgis >= 3.0, support GeometryCollection throughout
kleintom Jun 17, 2024
7066fe5
#1954 Mostly replace DATA_TYPES with SHAPE_TYPES in GeographicItem
kleintom Jun 17, 2024
b44320b
#1954 Expand and contract some switch statements, more geometry_colle…
kleintom Jun 17, 2024
0321144
#1954 Replace GeographicItem.are_contained_in_item_by_id with are_con…
kleintom Jun 18, 2024
ea6377e
#1954 Rewrite GeographicItem#intersecting_area
kleintom Jun 18, 2024
205b887
#1954 Deprecate the common subclass methods of GeographicItem
kleintom Jun 19, 2024
3a0d899
#1954 GeographicItem cleanup and formatting
kleintom Jun 19, 2024
27e5cdc
#1954 Move GeographicItem deprecated methods into their own module
kleintom Jun 19, 2024
976fb19
#1954 Rewrite GeographicItem query in CollectingEvent to not use GEOM…
kleintom Jun 20, 2024
7744094
#1954 Refactor GeographicItem ST_Covers/ST_CoveredBy methods
kleintom Jun 20, 2024
f852c51
#1954 Add GeographicItem.st_buffer_for_item
kleintom Jun 20, 2024
18cd583
#1954 Add and use GeographicItem.st_dwithin_sql
kleintom Jun 21, 2024
d91a3a4
#1954 Change GeographicItem.geometry_sql to items_as_one_geometry_sql
kleintom Jun 22, 2024
c46bf0f
#1954 Deprecate more GeographicItem methods
kleintom Jun 22, 2024
1088032
#1954 Move another outside use of GeographicItem internals to Geograp…
kleintom Jun 22, 2024
abb4722
#1954 Move a couple more GEOMETRY_SQL uses into GeographicItem
kleintom Jun 22, 2024
767c3cf
#1954 !!My be breaking!! - Clarify more containing/covering/coveredby…
kleintom Jun 22, 2024
d1d94f1
Make Leaflet map controls hideable and showable
kleintom Jun 23, 2024
b6eeecc
#1954 Make Leaflet drawing non-editable after initial draw
kleintom Jun 23, 2024
768ff75
#1954 Make name required before shape can be added
kleintom Jun 23, 2024
b4e24ee
#1954 Allow adding multiple shapes to a GZ in the UI
kleintom Jun 23, 2024
0b453cf
#1954 Accept multiple shapes in Gazetteer controller
kleintom Jun 23, 2024
b753cd5
#1954 Finish more of create Gazetteer, add _attributes.json.jbuilder
kleintom Jun 24, 2024
404b1f8
#1954 Support name update
kleintom Jun 24, 2024
c47ba44
#1954 Implement New button
kleintom Jun 24, 2024
9efd135
#1954 Move NavBar down a component
kleintom Jun 25, 2024
ef7f6d0
#1954 Move display list up a component, add source type to shapes
kleintom Jun 25, 2024
dd3b0e2
Generalize the WKT.vue component somewhat
kleintom Jun 25, 2024
9b76df1
#1954 Add support for WKT input
kleintom Jun 25, 2024
2cab3ae
#1954 Get index, list, show working
kleintom Jun 26, 2024
7aa9482
#1954 Add more st_*_sql methods to GeographicItem
kleintom Jun 26, 2024
eafa060
#1954 Move some Gazetteer methods from controller to model
kleintom Jun 29, 2024
8263c1a
#1954 Rework GeographicItem.to_geo_json
kleintom Jun 29, 2024
4b7c2ed
#1954 Drop `_item` from GeographicItem st_covers_item and st_coveredb…
kleintom Jun 30, 2024
2fa3f17
#1954 Fix geojson spec windings (because of fixed GeographicItem wind…
kleintom Jun 30, 2024
de42b5d
#1954 Change GeographicItem.within_radius_of_wkt to within_radius_of_…
kleintom Jun 30, 2024
599b3d6
#1954 Use Gazetteer.build_geographic_item in create
kleintom Jul 1, 2024
da30f45
#1954 Add more st_*_sql function and cleanup in GeographicItem
kleintom Jul 1, 2024
d5d33ee
#1954 Remove duplicated GoegraphicItem specs
kleintom Jul 2, 2024
8176923
#1954 De-deprecate GeographicItem.crosses_anti_meridian_by_id?
kleintom Jul 2, 2024
39feb83
#1954 Remove all deprecated GeographicItem methods and specs
kleintom Jul 2, 2024
7357d4d
#1954 Fix naming in GeographicItem
kleintom Jul 3, 2024
34032d7
#1954 Copy simple geographic_item_spec specs for geography
kleintom Jul 2, 2024
e1cf3c6
#1954 Fix bugs in GeographicItem st_covers and st_coveredby
kleintom Jul 3, 2024
1576853
#1954 Enable GeographicItem#shape= to assign to geography column
kleintom Jul 3, 2024
9390c93
#1954 Port existing GeographicItem specs to geography specs
kleintom Jul 3, 2024
759759c
#1954 Add some additional GeographicItem geography tests
kleintom Jul 6, 2024
68c8826
#1954 Remove/replace GeographicItem#rgeo_to_geo_json
kleintom Jul 7, 2024
841cc5f
#1954 Union multiple gazetteer shapes instead of collecting them
kleintom Jul 8, 2024
ae9d1ab
#1954 Make GeographicItem has_one gazetteer instead of has_many
kleintom Jul 9, 2024
0d1ab78
#1954 Make all new links for gazetteer link to the task
kleintom Jul 9, 2024
6245ee3
#1954 Enable editing of Gazetteers (non-shape data only)
kleintom Jul 9, 2024
b56ea75
#1954 Fix display of GeometryCollections in Gazetteer displaylist
kleintom Jul 10, 2024
0705733
Allow WKT modal button to be disabled
kleintom Jul 10, 2024
c2b5f65
Allow cached_total_area to be 0 in cached_map_item
kleintom Jul 10, 2024
defdef1
#1954 Don't confirm delete on Gazetter shapes during creation
kleintom Jul 10, 2024
2385dc1
#1954 Add better support for New Gazetteer New
kleintom Jul 10, 2024
4620ab7
#1954 Add autocomplete support for Gazetteer
kleintom Jul 10, 2024
15e860c
#1954 Add a kind of support for circles in Gazetteer
kleintom Jul 10, 2024
6f8c763
#1954 Add gazetteer_id query parameter when Gazetteer is saved
kleintom Jul 11, 2024
82eea4a
Merge branch 'development' into 1954_gazetteer
kleintom Jul 11, 2024
b55610c
#1954 Display the combined Gz shape on save
kleintom Jul 11, 2024
dca2bb0
#1954 Fix notifications, other cleanup
kleintom Jul 11, 2024
7dbe114
Merge branch 'development' into 1954_gazetteer
kleintom Jul 11, 2024
870bdc1
#1954 Rewrite GeoJson.quick_geo_json
kleintom Jul 11, 2024
8b1fa9c
#1954 Fix double typo in GeographicItem.covered_by_wkt_shifted_sql
kleintom Jul 12, 2024
ec9b713
#1954 Change names of st_isvalid, st_isvalidreason, add specs
kleintom Jul 12, 2024
0323104
#1954 Add GazetteerFacet
kleintom Jul 14, 2024
136731e
#1954 Support FacetGazetteer in filters
kleintom Jul 14, 2024
f07796e
#1954 Singularize filter `gazetteer_ids` to `gazetteer_id`
kleintom Jul 15, 2024
d25364f
#1954 Add some specs for filtering on gzs
kleintom Jul 17, 2024
5a834b9
#1954 Move more Gazetteer creation from controller into model
kleintom Jul 16, 2024
7cb8168
#1954 Cleanup uuid and prop casing for New Gazetteer
kleintom Jul 16, 2024
469bf28
#1954 Avoid instantiating parent shapes in definition of child shapes
kleintom Jul 16, 2024
d51aedb
#1954 Make separate geo objects for distance specs
kleintom Jul 16, 2024
2c5c402
#1954 Rename shared_geo_for_geography to shared_basic_geo
kleintom Jul 16, 2024
6c6745d
#1954 Recreate scope tests for GeographicItem geographic column specs
kleintom Jul 16, 2024
a7485c0
#1954 Remove New Gazetteers task from filters category
kleintom Jul 17, 2024
95a595a
#1954 Rewrite GeographicItem st_* methods using Arel
kleintom Jul 19, 2024
9727d6e
#1954 Add a gazetteers query concern
kleintom Jul 24, 2024
e975bef
#1954 Create Queries::GeographicItem, move st_union to it
kleintom Jul 24, 2024
7aaf025
Make Georef's 'Enter coordinates' component usable for non-georef uses
kleintom Jul 25, 2024
0d65067
#1954 Support entering point coordinates by hand in the New GZ UI
kleintom Jul 25, 2024
f5baca8
#1954 Support creating gazetteer from user-entered point coordinates
kleintom Jul 25, 2024
52a9397
#1954 Clarify some geometric vs geographic computations
kleintom Jul 25, 2024
a95a0b5
#1954 Remove spec/models/geographic_item.spec
kleintom Jul 26, 2024
0e047e0
#1954 Rename gi/geography_spec.rb to geographic_item_spec.rb
kleintom Jul 26, 2024
adbedab
#1954 Remove specs for non-geography gi types
kleintom Jul 26, 2024
0c364eb
#1954 Remove unused shapes in shared_geo
kleintom Jul 26, 2024
d5fc35e
#1954 Move non-Leaflet input components into their own component
kleintom Jul 26, 2024
12621c0
#1954 Support upload of shapefile documents
kleintom Jul 27, 2024
0c69de6
Make FilterDocument not nexus-specific
kleintom Jul 28, 2024
245015f
#1954 Create Import gazetteers task
kleintom Jul 28, 2024
b5bff3f
Rework extension groups to specify content_type per extension
kleintom Jul 28, 2024
effabd1
#1954 Create a DocumentSelector for gazetteer shapefile documents
kleintom Jul 28, 2024
db4f6ae
#1954 Get set up to process a shapefile into gazetteers
kleintom Jul 28, 2024
f47e3fb
#1954 Link shapefile parts from temporary directory
kleintom Jul 28, 2024
65cb8e0
Add rgeo-shapefile gem
kleintom Jul 29, 2024
63d1bef
#1954 First full support for converting shapefile to gzs
kleintom Jul 29, 2024
8c8672b
#1954 Return and display results of processing a shapefile
kleintom Jul 29, 2024
20f661a
#1954 Add Import Gazetteers to the gazetteers navigator radial
kleintom Jul 30, 2024
c2e3002
#1954 Fix document filter specs (filter attr_accessor name changed)
kleintom Jul 30, 2024
d699a9d
#1954 Some cleanup
kleintom Jul 30, 2024
dd465e9
Merge branch 'development' into 1954_gazetteer
kleintom Jul 30, 2024
2999c88
#1954 Support setting iso_3166_a2 and a3 codes in New Gz
kleintom Jul 30, 2024
6fc6226
Convert georef wkt entry to vue component style
kleintom Jul 31, 2024
3e78095
Focus inputs of WKT and point modals when shown
kleintom Jul 31, 2024
5698301
#1954 Migrate GI: copy current shape columns to geography, delete typ…
kleintom Aug 1, 2024
4d710bf
#1954 Get GeographicItem specs passing again for single geography column
kleintom Aug 1, 2024
4841dbb
#1954 Get all other specs passing after GI move to geography column
kleintom Aug 2, 2024
7525cfe
#1954 Add GI scopes for each shape type to scope to shapes of that type
kleintom Aug 2, 2024
0b95e00
#1954 Formalize qoute_string calls in GI
kleintom Aug 3, 2024
b974a2e
Document unfortunate leaflet/GeoJSON.decode interaction
kleintom Aug 3, 2024
060d6a4
#1954 Frontend validate shapefile files for Import Gazetteer
kleintom Aug 3, 2024
292d3ce
#1954 Make invalid shapefile records valid on import for GZs
kleintom Aug 3, 2024
b8e55ba
#1954 Fix some GI join scope merges
kleintom Aug 4, 2024
c5a262b
#1954 Cleanup
kleintom Aug 4, 2024
66e44b3
Make marking search term in GA autocomplete results optional
kleintom Aug 5, 2024
ef15469
GeographicArea.geo_object should return an RGeo object, not a GI
kleintom Aug 5, 2024
609b837
#1954 Support for adding GAs to a GZ
kleintom Aug 5, 2024
0f69963
#1954 Support for adding GZs to a GZ
kleintom Aug 6, 2024
9608daf
#1954 Add GazetteerController#preview action
kleintom Aug 6, 2024
11687f7
#1954 Support Preview GZ in the UI
kleintom Aug 7, 2024
a527ab2
#1954 Validate component GZ shapes as they're converted to RGeo
kleintom Aug 7, 2024
03fef06
#1954 Disable save if there's exactly one GA or one GZ
kleintom Aug 7, 2024
45fb81b
#1954 Cache the preview shape in New GZ
kleintom Aug 7, 2024
599c642
#1954 Adjust error conditions on Gazetteer shapefile import
kleintom Aug 16, 2024
429bf65
#1954 Validate shapefile attributes on import before background job
kleintom Aug 16, 2024
4429fd4
#1954 Remove error reporting to UI on import
kleintom Aug 17, 2024
9cd7b27
Merge branch 'development' into 1954_gazetteer
kleintom Aug 26, 2024
f267f00
#1954 Allow Gz preview with only one shape
kleintom Aug 27, 2024
bacbcbf
#1954 Move gazetteers import to a background job
kleintom Aug 27, 2024
12f45dd
#1954 Check that the shapefile prj is WGS 84
kleintom Sep 4, 2024
09cd6de
#1954 Add GazetteerImport model for tracking import jobs
kleintom Sep 10, 2024
1cf8e05
#1954 Record progress during gazetteer shapefile imports
kleintom Sep 10, 2024
f5571bd
#1954 Add GazetteerImport endpoint
kleintom Sep 10, 2024
6531e04
#1954 Display list of GZ import jobs in Import task
kleintom Sep 11, 2024
b82bce4
#1954 Abandon progress updates during import transaction
kleintom Sep 11, 2024
c398bb9
#1954 Update job import list functionality
kleintom Sep 11, 2024
1401569
#1954 Refresh jobs list when a new import job is posted
kleintom Sep 12, 2024
2f94e31
#1954 Include submitter with import job info
kleintom Sep 12, 2024
bb64cc3
#1954 Offer shapefile field names lookup
kleintom Sep 13, 2024
d50f31f
#1954 Allow any GazetteerImport job to be deleted after one day
kleintom Sep 15, 2024
5397c60
#1954 Add citation options for GZ imports to the UI
kleintom Sep 18, 2024
92f9a26
Merge branch 'development' into 1954_gazetteer
kleintom Sep 18, 2024
d8ebcd5
#1954 Support citing GZs on import on the backend
kleintom Sep 18, 2024
e0e3ce8
#1954 Only need to validate user input shapes, not existing GAs and GZs
kleintom Sep 24, 2024
f5331e4
#1954 Prevent empty required citations param error
kleintom Sep 25, 2024
5b89233
#1954 Tweak prj checking on GZ shapefile imports
kleintom Sep 25, 2024
e5e8056
#1954 Rework dbf name field checking on GZ shapefile import
kleintom Sep 25, 2024
5b8fdb1
#1954 Rework GZ import citation options UI
kleintom Sep 26, 2024
0efccac
#1954 Add specs for Gazetteer#build_gi_from_shapes
kleintom Sep 27, 2024
f049541
#1954 Turn off preview on save, use spinner on save and update New Gz
kleintom Sep 29, 2024
e4db65c
#1954 Split anti-meridian crossing shapes across anti-mer. on New Gz …
kleintom Sep 29, 2024
5269897
#1954 Update anti_meridian_spec.rb postgis assumptions
kleintom Sep 30, 2024
0554fbf
#1954 Document valid leaflet anti-meridian shapes becoming invalid in…
kleintom Oct 1, 2024
af8e4d8
#1954 Add anti-meridian specs related to split_along_anti_meridian
kleintom Oct 1, 2024
ad5c9ac
#1954 Tweak New GZ handling of page load with gazetteer_id= query par…
kleintom Oct 1, 2024
fed5239
#1954 Fix display of shape coordinates for New Gz shapes
kleintom Oct 2, 2024
2dfc973
#1954 Truncate coordinates display in New GZ
kleintom Oct 2, 2024
8506e60
#1954 Make GeometryCollection inside GeometryCollection unsupported
kleintom Oct 3, 2024
43f68af
#1954 Catch file-not-found/unopenable errors on GZ import
kleintom Oct 6, 2024
378bf1f
#1954 Fix/extend name field checking for GZ import
kleintom Oct 6, 2024
c3db241
#1954 Add specs for import_gazetteers_job
kleintom Oct 7, 2024
69cec94
#1954 Move GZ shapefile import processing to lib/vendor/rgeo_shapefil…
kleintom Oct 7, 2024
1b3e787
#1954 Move shapefile helper code to rgeo_shapefile_helper.rb
kleintom Oct 7, 2024
4d46913
#1954 Add rgeo_shapefile_helper_spec.rb
kleintom Oct 7, 2024
ebab6cb
#1954 Refactor to ensure tmp files are removed on error
kleintom Oct 8, 2024
958845e
#1954 Add link to /gazetteers in import jobs header
kleintom Oct 9, 2024
f050c36
#1954 Fixup (unused) GeographicItem filter to get specs to pass
kleintom Oct 9, 2024
2f46ce2
Merge commit '3c1b945ae29c4659a7f9e889222b' into 1954_gazetteer
kleintom Oct 9, 2024
a797577
#1954 Get the marker icon added to the Gazetteer hub data card
kleintom Oct 9, 2024
bf7cfe8
#1954 Only require a .shp file to be specified for importing a shapefile
kleintom Oct 10, 2024
4530820
#1954 Check for nil_squish_strip shapefile name values instead of nil/''
kleintom Oct 11, 2024
a972fa1
#1954 Add special case single point longitude normalizing for New GZ
kleintom Oct 11, 2024
19f71fc
#1954 Drop currently unused has_closure_tree from Gazetteer
kleintom Oct 11, 2024
e2ac42e
#1954 Cleanup
kleintom Oct 11, 2024
3e1cb99
#1954 Fix indenting in GeographicItem.rb
kleintom Oct 12, 2024
62e05e2
#1954 Add GeographicItem#circle specs
kleintom Oct 12, 2024
09aaefa
#1954 Allow more WGS84 names coming from shapefile prj files
kleintom Oct 12, 2024
d038af3
#1954 Handle errors on New Gz preview
kleintom Oct 12, 2024
f9c133c
Merge branch 'development' into 1954_gazetteer
kleintom Oct 12, 2024
92e8da1
#1954 Cleanup
kleintom Oct 13, 2024
b6509de
#1954 Fix st_is_valid spec for invalid case
kleintom Oct 13, 2024
e7237c6
#1954 Add a GeographicItem.intersecting_radius_of_wkt_sql spec
kleintom Oct 13, 2024
156de8f
#1954 Remove references to GZ parent that were missed earlier
kleintom Oct 13, 2024
f767709
#1954 Change name of the new/edit GZ task
kleintom Oct 13, 2024
92630ea
#1954 Arel-ize GeographicItem.lat_long_sql, refactor center_coords
kleintom Oct 17, 2024
0a3589f
#1954 Split GZ shapeile import shapes along anti-meridian
kleintom Oct 19, 2024
06edd42
#1954 Make GI has_many GZs (instead of has_one), for multi-project GZ…
kleintom Oct 21, 2024
8954224
#1954 Support saving to multiple projects in New GZ
kleintom Oct 22, 2024
273991d
#1954 Support importing GZs to multiple projects from shapefile
kleintom Oct 22, 2024
2eebd8c
#1954 Add specs for creating/importing GZs into multiple projects
kleintom Oct 23, 2024
d93d35e
#1954 Reset input fields after GZ import submission
kleintom Oct 23, 2024
4d014a9
#1954 Add a Gazetteers link to the New GZ task
kleintom Oct 23, 2024
668bdaa
#1954 Require modal confirmation on selecting shapefile name field
kleintom Oct 24, 2024
7544f22
#1954 Add project_names field to GazetteerImport
kleintom Oct 24, 2024
69f4fad
#1954 Rework saving/cloning GZs into multiple projects
kleintom Oct 25, 2024
6fe09b0
#1954 Abandon using one large transaction on GZ imports
kleintom Oct 25, 2024
c81302e
#1954 Cleanup Gazetteer/GazetteerImport views folders and import routes
kleintom Oct 25, 2024
c5ecead
#1954 Support import of iso a2/a3 fields from shapefile in the ui
kleintom Oct 26, 2024
afb6275
#1954 Support importing iso a2/a3 from shapefile in GZ import, add specs
kleintom Oct 26, 2024
f854701
#1954 Improve Gazetteer autocomplete
kleintom Oct 27, 2024
75d1925
#1954 Enable download for Gazetteers
kleintom Oct 27, 2024
34a8ef7
#1954 Actually remove has_closure_tree parent_id from Gazetteer
kleintom Oct 27, 2024
1407031
#1954 Test for and split anti_meridian_crossing shapes before doing m…
kleintom Oct 28, 2024
e3ec3aa
#1954 Add specs for importing shapefiles with invalid/special shapes
kleintom Oct 29, 2024
588a414
#1954 Add support for shapefile .cpg for attribute encoding information
kleintom Oct 29, 2024
7279308
#1954 Abort on unrecognized .cpg encoding
kleintom Oct 29, 2024
8c52639
Merge branch 'development' into 1954_gazetteer
kleintom Oct 30, 2024
3d66998
#1954 Move gazetteer_controller#import code to helper
kleintom Oct 31, 2024
f9f6658
#1954 Finish documenting new understanding of anti_meridian behavior
kleintom Nov 1, 2024
0606071
#1954 Unify creation of valid, non-anti-meridian-crossing shapes
kleintom Nov 1, 2024
233a686
Merge branch 'development' into 1954_gazetteer
kleintom Nov 2, 2024
32f8017
#1954 Fix missing key for params to ST_MakeValid
kleintom Nov 2, 2024
29fabd0
#1954 Rework old migration to not reference recently removed class
kleintom Nov 5, 2024
01af162
#1954 Restrict possible ST_MakeValid keep_collapsed values
kleintom Nov 6, 2024
d7ee094
Copy the content of @LocoDelAssembly's pr for Rails 7.2 setup
kleintom Nov 7, 2024
6dc3893
Fix type inference for bound parameter issue arising with Rails 7.2
kleintom Nov 7, 2024
84146f1
#1954 Always keepcollapsed=false for ST_MakeValid
kleintom Nov 12, 2024
d5e10a3
#1954 Add specs to document Gis::FACTORY latitude clamping
kleintom Nov 13, 2024
3534435
#1954 Remove ST_MakeValid params for now(!), waiting for GEOS >= 3.10
kleintom Nov 13, 2024
75c0471
Merge branch 'development' into 1954_gazetteer
kleintom Nov 13, 2024
963a31d
#1954 Undo the migration to drop `type` from GeographicItem for now
kleintom Nov 13, 2024
036b85c
#1954 Restore GI `type` column, take 2
kleintom Nov 16, 2024
c9bded7
#1954 Add Gazetteer to GeographicItem related models
kleintom Nov 17, 2024
3878bb3
#1954 Add GI before_save to normalize point lons to be saved in db
kleintom Nov 17, 2024
c1a5033
#1954 Use select_value instead of execute for GI's ::select_one
kleintom Nov 17, 2024
f4572ae
#1954 Make GI::circle return a non-anti-meridian crossing shape
kleintom Nov 17, 2024
594404a
#1954 Document postgis interpretation of edges for ::crosses_anti_mer…
kleintom Nov 18, 2024
6f772e3
Merge branch 'development' into 1954_gazetteer
kleintom Nov 18, 2024
31f0346
#1954 Add import_gazetteers queue to app/exe/delayed_job
kleintom Nov 21, 2024
1d90ace
Merge branch 'development' into 1954_gazetteer
kleintom Dec 11, 2024
8395dc0
Add require for use of Queries::GeographicItem.st_union in 7.2
kleintom Dec 11, 2024
2b79159
#1954 Move lib/vendor/rgeo_shapefile.rb content to Gazetteer
kleintom Dec 12, 2024
13f6ee1
#1954 Still require .prj for shapefiles, but don't require it to be W…
kleintom Dec 12, 2024
dc3920b
#1954 You don't need an SRID just to create a factory or transform
kleintom Dec 13, 2024
9ec5797
#1954 Adjust messaging on which shapefile files are required
kleintom Dec 14, 2024
2b1a6c4
#1954 Clear (some) error fields when GZ Import validation fails
kleintom Dec 14, 2024
8da33f6
#1954 Update specs for now-working 'invalid anti-meridian-crossing' i…
kleintom Dec 15, 2024
5eb026c
#1954 Provide intersection operation for New GZ in addition to union
kleintom Dec 15, 2024
5f12d70
#1954 Only show editable inputs in New GZ once a gz has been saved
kleintom Dec 15, 2024
12bfe88
#1954 Fix otu filter on GZ
kleintom Dec 15, 2024
e704680
#1954 Reset selected radio doc in Import Gz when job is submitted
kleintom Dec 15, 2024
b1142d3
#1954 Add helper to know which shapefile files have/not been added to…
kleintom Dec 16, 2024
0f9b0a2
Merge branch 'development' into 1954_gazetteer
kleintom Dec 16, 2024
73d0d6e
#1954 Update naming now that New GZ supports intersection as well as …
kleintom Dec 16, 2024
fed81c1
#1954 Add 'intersection or union' to the preview cache in New GZ
kleintom Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions app/controllers/gazetteers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
class GazetteersController < ApplicationController
include DataControllerConfiguration::ProjectDataControllerConfiguration
before_action :set_gazetteer, only: %i[ show edit update destroy ]

# GET /gazetteers
# GET /gazetteers.json
def index
respond_to do |format|
format.html do
@recent_objects = Gazetteer.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
render '/shared/data/all/index'
end
format.json do
# TODO gzs, not gas
@geographic_areas = ::Queries::GeographicArea::Filter.new(params).all
kleintom marked this conversation as resolved.
Show resolved Hide resolved
.includes(:geographic_items)
.page(params[:page])
.per(params[:per])
# .order('geographic_items.cached_total_area, geographic_area.name')
end
end
end

# GET /gazetteers/1 or /gazetteers/1.json
def show
end

# GET /gazetteers/new
def new
respond_to do |format|
format.html { redirect_to new_gazetteer_task_path }
end
end

# GET /gazetteers/1/edit
def edit
respond_to do |format|
format.html { redirect_to new_gazetteer_task_path gazetteer_id: @gazetteer.id }
end
end

# GET /gazetteers/list
def list
@gazetteers = Gazetteer
.with_project_id(sessions_current_project_id)
.page(params[:page]).per(params[[:per]])
end

# POST /gazetteers.json
def create
@gazetteer = Gazetteer.new(gazetteer_params)

begin
kleintom marked this conversation as resolved.
Show resolved Hide resolved
rgeo_shape = Gazetteer.combine_shapes_to_rgeo(shape_params['shapes'])
# TODO make sure these errors work
rescue RGeo::Error::RGeoError => e
@gazetteer.errors.add(:base, e)
rescue RGeo::Error::InvalidGeometry => e
@gazetteer.errors.add(:base, "Invalid geometry: #{e}")
rescue TaxonWorks::Error => e
@gazetteer.errors.add(:base, e)
end

if @gazetteer.errors.include?(:base) || rgeo_shape.nil?
render json: @gazetteer.errors, status: :unprocessable_entity
return
end

@gazetteer.build_geographic_item(
kleintom marked this conversation as resolved.
Show resolved Hide resolved
type: 'GeographicItem::Geography',
geography: rgeo_shape
)

if @gazetteer.save
render :show, status: :created, location: @gazetteer
else
render json: @gazetteer.errors, status: :unprocessable_entity
end
end

# PATCH/PUT /gazetteers/1
# PATCH/PUT /gazetteers/1.json
def update
respond_to do |format|
if @gazetteer.update(gazetteer_params)
format.html { redirect_to gazetteer_url(@gazetteer) }
format.json { render :show, status: :ok }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @gazetteer.errors, status: :unprocessable_entity }
end
end
end

# DELETE /gazetteers/1
# DELETE /gazetteers/1.json
def destroy
# TODO Handle children/parents (if used)
@gazetteer.destroy!

respond_to do |format|
format.html {
redirect_to gazetteers_url,
# TODO this doesn't work
notice: 'Gazetteer was successfully destroyed.'
}
format.json { head :no_content }
end
end

def autocomplete
@gazetteers = ::Queries::Gazetteer::Autocomplete.new(
params.require(:term),
project_id: sessions_current_project_id,
).autocomplete
end

def search
if params[:id].blank?
redirect_to(gazetteer_path,
alert: 'You must select an item from the list with a click or tab press before clicking show.')
else
redirect_to gazetteer_path(params[:id])
end
end

private

def set_gazetteer
@gazetteer = Gazetteer.find(params[:id])
end

def gazetteer_params
params.require(:gazetteer).permit(:name, :parent_id,
:iso_3166_a2, :iso_3166_a3)
end

def shape_params
params.require(:gazetteer).permit(shapes: { geojson: [], wkt: []})
end


end
4 changes: 4 additions & 0 deletions app/controllers/tasks/gazetteers/new_gazetteer_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Tasks::Gazetteers::NewGazetteerController < ApplicationController
include TaskControllerConfiguration

end
4 changes: 2 additions & 2 deletions app/controllers/tasks/gis/match_georeference_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def drawn_collecting_events
when 'polygon'
@collecting_events = CollectingEvent.with_project_id(sessions_current_project_id)
.joins(:geographic_items)
.where(GeographicItem.contained_by_wkt_sql(geometry))
.where(GeographicItem.covered_by_wkt_sql(geometry))
else
end
end
Expand Down Expand Up @@ -143,7 +143,7 @@ def drawn_georeferences
when 'polygon'
@georeferences = Georeference.with_project_id(sessions_current_project_id)
.joins(:geographic_item)
.where(GeographicItem.contained_by_wkt_sql(geometry))
.where(GeographicItem.covered_by_wkt_sql(geometry))
else
end
if @georeferences.blank?
Expand Down
3 changes: 1 addition & 2 deletions app/helpers/collecting_events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ def collecting_event_to_simple_json_feature(collecting_event)

if collecting_event.geographic_items.any?
geo_item_id = collecting_event.geographic_items.select(:id).first.id
query = "ST_AsGeoJSON(#{GeographicItem::GEOMETRY_SQL.to_sql}::geometry) geo_json"
base['geometry'] = JSON.parse(GeographicItem.select(query).find(geo_item_id).geo_json)
base['geometry'] = GeographicItem.find(geo_item_id).to_geo_json
end
base
end
Expand Down
33 changes: 33 additions & 0 deletions app/helpers/gazetteers_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module GazetteersHelper
def gazetteer_tag(gazetteer)
return nil if gazetteer.nil?
gazetteer.name
end

def label_for_gazetteer(gazetteer)
return nil if gazetteer.nil?
gazetteer.name
end

def gazetteer_link(gazetteer, link_text = nil)
return nil if gazetteer.nil?
link_text ||= gazetteer.name
link_to(link_text, gazetteer)
end

def gazetteer_link_list(gazetteers)
content_tag(:ul) do
gazetteers.collect { |a| content_tag(:li, gazetteer_link(a)) }.join.html_safe
end
end

def gazetteer_autocomplete_tag(gazetteer)
gazetteer_tag(gazetteer)
end

def gazetteers_search_form
render('/gazetteers/quick_search_form')
end


end
4 changes: 2 additions & 2 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ import '../vue/tasks/otus/new_otu/main.js'
import '../vue/tasks/leads/hub/main.js'
import '../vue/tasks/data_attributes/field_synchronize/main.js'
import '../vue/tasks/observation_matrices/import_nexus/main.js'

import '../vue/tasks/dwc_occurrences/filter/main.js'
import '../vue/tasks/dwc_occurrences/filter/main.js'
import '../vue/tasks/gazetteers/new_gazetteer/main.js'
48 changes: 33 additions & 15 deletions app/javascript/vue/components/georeferences/map.vue
kleintom marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ let geographicArea

const TILE_MAP_STORAGE_KEY = 'tw::map::tile'

const DRAW_CONTROLS_PROPS = [
'drawCircle',
'drawCircleMarker',
'drawMarker',
'drawPolyline',
'drawPolygon',
'drawRectangle',
'drawText',
'editMode',
'dragMode',
'cutPolygon',
'removalMode',
'rotateMode'
]

const props = defineProps({
zoomAnimate: {
type: Boolean,
Expand Down Expand Up @@ -198,6 +213,13 @@ watch(
}
)

watch(
() => props.drawControls,
(newVal) => {
mapObject.pm.addControls(getControls(newVal))
}
)

onMounted(() => {
mapObject = L.map(leafletMap.value, {
center: props.center,
Expand Down Expand Up @@ -245,6 +267,15 @@ onUnmounted(() => {
observeMap?.disconnect()
})

function getControls(show) {
let controls = { position: 'topleft' }
DRAW_CONTROLS_PROPS.forEach((prop) => {
controls[prop] = show ? props[prop] : false
})

return controls
}

const addDrawControllers = () => {
getDefaultTile().addTo(mapObject)
if (props.tilesSelection) {
Expand All @@ -254,21 +285,7 @@ const addDrawControllers = () => {
}

if (props.drawControls) {
mapObject.pm.addControls({
position: 'topleft',
drawCircle: props.drawCircle,
drawCircleMarker: props.drawCircleMarker,
drawMarker: props.drawMarker,
drawPolyline: props.drawPolyline,
drawPolygon: props.drawPolygon,
drawRectangle: props.drawRectangle,
drawText: props.drawText,
editMode: props.editMode,
dragMode: props.dragMode,
cutPolygon: props.cutPolygon,
removalMode: props.removalMode,
rotateMode: props.rotateMode
})
mapObject.pm.addControls(getControls(true))
}

if (!props.actions) {
Expand All @@ -277,6 +294,7 @@ const addDrawControllers = () => {
})
}
}

const handleEvents = () => {
mapObject.on('baselayerchange', (e) => {
localStorage.setItem(TILE_MAP_STORAGE_KEY, e.name)
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/vue/constants/gazetteerTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//export const GEOREFERENCE_GEOLOCATE = 'Georeference::GeoLocate'
export const GZ_LEAFLET = 'Leaflet'
export const GZ_POINT = 'Point'
export const GZ_WKT = 'WKT'
1 change: 1 addition & 0 deletions app/javascript/vue/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './dataAttributes'
export * from './descriptorTypes'
export * from './downloadTypes'
export * from './events'
export * from './gazetteerTypes'
export * from './georeferenceTypes'
export * from './identifierTypes'
export * from './importDataset'
Expand Down
17 changes: 17 additions & 0 deletions app/javascript/vue/routes/endpoints/Gazetteer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import baseCRUD from './base'
import AjaxCall from '@/helpers/ajaxCall.js'

const controller = 'gazetteers'
const permitParams = {
gazetteer: {
name: String,
shapes: {
geojson: [],
wkt: []
}
}
}

export const Gazetteer = {
...baseCRUD(controller, permitParams)
}
1 change: 1 addition & 0 deletions app/javascript/vue/routes/endpoints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export { Documentation } from './Documentation'
export { Download } from './Download'
export { DwcOcurrence } from './DwcOcurrence'
export { Extract } from './Extract'
export { Gazetteer } from './Gazetteer'
export { GeographicArea } from './GeographicArea'
export { Georeference } from './Georeference'
export { Identifier } from './Identifier'
Expand Down
1 change: 1 addition & 0 deletions app/javascript/vue/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const RouteNames = {
'/tasks/biological_associations/biological_associations_graph',
NewCollectingEvent: '/tasks/collecting_events/new_collecting_event',
NewExtract: '/tasks/extracts/new_extract',
NewGazetteer: '/tasks/gazetteers/new_gazetteer',
NewLead: '/tasks/leads/new_lead',
NewNamespace: '/tasks/namespaces/new_namespace',
NewObservationMatrix: '/tasks/observation_matrices/new_matrix',
Expand Down
Loading