Skip to content

Commit 829a1c5

Browse files
committed
TAX-80 | Change Geoserver to use taxomap_with_ancestors view
1 parent 951bad2 commit 829a1c5

8 files changed

Lines changed: 96 additions & 17 deletions

File tree

‎client/src/wfs/wfs.spec.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ describe('wfs', () => {
5454
// THEN
5555
const params = validateUrlAndGetParams(format, urlString);
5656
expect(params.get('cql_filter')).to.equal('family_id = 1 ' +
57-
'AND institutioncode_id = 2 AND basisofrecord_id = 3 AND genus IN (1,3) ' +
57+
'AND institution_id = 2 AND basis_of_record_id = 3 AND genus IN (1,3) ' +
5858
'AND year >= 1920 AND year <= 2010 ' +
59-
'AND BBOX(geom,0.5,42.7,0.6,42.8)');
59+
'AND BBOX(geometry,0.5,42.7,0.6,42.8)');
6060
});
6161

6262
it('getWfsDownloadUrl returns URL with all subtaxa visible"', async () => {
@@ -174,8 +174,8 @@ describe('wfs', () => {
174174
year: 2023,
175175
month: 11,
176176
county: 'Burjassot',
177-
stateprovince: 'Valencia',
178-
scientificname: 'Ornithorhynchus anatinus'
177+
state_province: 'Valencia',
178+
scientific_name: 'Ornithorhynchus anatinus'
179179
}
180180
}]
181181
};
@@ -190,8 +190,8 @@ describe('wfs', () => {
190190
expect(properties?.day).to.equal(undefined);
191191
expect(properties?.municipality).to.equal(undefined);
192192
expect(properties?.county).to.equal(response.features[0].properties.county);
193-
expect(properties?.stateProvince).to.equal(response.features[0].properties.stateprovince);
194-
expect(properties?.scientificName).to.equal(response.features[0].properties.scientificname);
193+
expect(properties?.stateProvince).to.equal(response.features[0].properties.state_province);
194+
expect(properties?.scientificName).to.equal(response.features[0].properties.scientific_name);
195195
});
196196

197197
const validateUrlAndGetParams = (expectedFormat: string, urlString: string): URLSearchParams => {

‎client/src/wfs/wfs.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export const WFS_TYPENAME = 'taxomap:taxomap';
88
* These depend on how the database is generated. Make sure they always match whatever is done in `91-generate-dictionaries.sql`.
99
*/
1010
export enum WFS_PROPERTY {
11-
institutionCodeId = 'institutioncode_id',
12-
basisOfRecordId = 'basisofrecord_id',
11+
institutionCodeId = 'institution_id',
12+
basisOfRecordId = 'basis_of_record_id',
1313
year = 'year',
1414
month = 'month',
1515
day = 'day',
1616
municipality = 'municipality',
1717
county = 'county',
18-
stateProvince = 'stateprovince',
19-
geometry = 'geom',
20-
scientificName = 'scientificname'
18+
stateProvince = 'state_province',
19+
geometry = 'geometry',
20+
scientificName = 'scientific_name'
2121
}
2222

2323
export type WfsProperties = { [key in (keyof typeof WFS_PROPERTY)]?: number | string | undefined }

devops/geoserver_data_dir/gwc-layers/LayerInfoImpl-5ccea8b4_18b6607e1b0_-7fff.xml renamed to devops/geoserver_data_dir/gwc-layers/LayerInfoImpl-16b80d9b_199389709ba_-7ffe.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<GeoServerTileLayer>
2-
<id>LayerInfoImpl-5ccea8b4:18b6607e1b0:-7fff</id>
2+
<id>LayerInfoImpl-16b80d9b:199389709ba:-7ffe</id>
33
<enabled>true</enabled>
44
<inMemoryCached>true</inMemoryCached>
55
<name>taxomap:taxomap</name>

‎devops/geoserver_data_dir/workspaces/taxomap/taxomap-db/taxomap/featuretype.xml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<featureType>
2-
<id>FeatureTypeInfoImpl-5ccea8b4:18b6607e1b0:-8000</id>
2+
<id>FeatureTypeInfoImpl-16b80d9b:199389709ba:-7fff</id>
33
<name>taxomap</name>
44
<nativeName>taxomap</nativeName>
55
<namespace>
@@ -36,6 +36,22 @@
3636
</latLonBoundingBox>
3737
<projectionPolicy>FORCE_DECLARED</projectionPolicy>
3838
<enabled>true</enabled>
39+
<metadata>
40+
<entry key="JDBC_VIRTUAL_TABLE">
41+
<virtualTable>
42+
<name>taxomap</name>
43+
<sql>select * from taxomap_with_ancestors
44+
</sql>
45+
<escapeSql>false</escapeSql>
46+
<keyColumn>id</keyColumn>
47+
<geometry>
48+
<name>geom</name>
49+
<type>Point</type>
50+
<srid>4326</srid>
51+
</geometry>
52+
</virtualTable>
53+
</entry>
54+
</metadata>
3955
<store class="dataStore">
4056
<id>DataStoreInfoImpl-2f64ed73:18b65fd00fb:-7ffe</id>
4157
</store>
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<layer>
22
<name>taxomap</name>
3-
<id>LayerInfoImpl-5ccea8b4:18b6607e1b0:-7fff</id>
3+
<id>LayerInfoImpl-16b80d9b:199389709ba:-7ffe</id>
44
<type>VECTOR</type>
55
<defaultStyle>
66
<id>StyleInfoImpl--570ae188:124761b8d78:-7fdf</id>
77
</defaultStyle>
88
<resource class="featureType">
9-
<id>FeatureTypeInfoImpl-5ccea8b4:18b6607e1b0:-8000</id>
9+
<id>FeatureTypeInfoImpl-16b80d9b:199389709ba:-7fff</id>
1010
</resource>
1111
<attribution>
1212
<logoWidth>0</logoWidth>
1313
<logoHeight>0</logoHeight>
1414
</attribution>
15-
<dateCreated>2023-10-25 08:51:14.521 UTC</dateCreated>
15+
<dateCreated>2025-09-11 11:45:06.395 UTC</dateCreated>
16+
<dateModified>2025-09-11 11:48:58.927 UTC</dateModified>
1617
</layer>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.db import migrations
2+
3+
from api.common.migrations import get_script_sql
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
('api', '0006_basis_of_record_institution_tables'),
9+
]
10+
11+
operations = [
12+
migrations.RunSQL(get_script_sql('0007_update_taxomap_with_ancestors_for_geoserver.sql'))
13+
]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
drop view taxomap_with_ancestors;
2+
create view taxomap_with_ancestors (
3+
id,
4+
catalog_number,
5+
scientific_name,
6+
domain_id, kingdom_id, phylum_id, class_id, order_id, family_id, genus_id, species_id, subspecies_id,
7+
basis_of_record_id, institution_id,
8+
year, month, day,
9+
municipality, county, state_province,
10+
geometry)
11+
as
12+
select taxomap.id,
13+
taxomap.catalognumber as catalog_number,
14+
backbone.canonical_name as scientific_name,
15+
1 as domain_id,
16+
backbone.kingdom_id as kingdom_id,
17+
backbone.phylum_id as phylum_id,
18+
backbone.class_id as class_id,
19+
backbone.order_id as order_id,
20+
backbone.family_id as family_id,
21+
backbone.genus_id as genus_id,
22+
backbone.species_id as species_id,
23+
backbone.subspecies_id as subspecies_id,
24+
taxomap.basisofrecord_id as basis_of_record_id,
25+
taxomap.institutioncode_id as institution_id,
26+
taxomap.year,
27+
taxomap.month,
28+
taxomap.day,
29+
taxomap.municipality,
30+
taxomap.county,
31+
taxomap.stateprovince as state_province,
32+
taxomap.geom as geometry
33+
from taxomap left join backbone_with_ancestors backbone
34+
on taxomap.backbone_id = backbone.id;

‎server/api/services/gdal_service.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,22 @@ def _get_ogr_command() -> str:
4444
' -lco COMPRESSION=NONE'
4545
' -lco BATCH_SIZE=999999'
4646
' -sql '
47-
'"select * from taxomap_with_ancestors"'
47+
'"select id,'
48+
' catalog_number as catalognumber, '
49+
' domain_id as domain, '
50+
' kingdom_id as kingdom, '
51+
' phylum_id as phylum, '
52+
' class_id as class, '
53+
' order_id as \\"order\\", '
54+
' family_id as family, '
55+
' genus_id as genus, '
56+
' species_id as species, '
57+
' subspecies_id as subspecies, '
58+
' basis_of_record_id as basisofrecord, '
59+
' institution_id as institutioncode, '
60+
' year, '
61+
' geometry as geom '
62+
'from taxomap_with_ancestors"'
4863
' -dialect OGRSQL'
4964
' /gdal-outputs/taxomap.arrow'
5065
f' postgresql://{user}:{password}@taxomap-database/taxomap'

0 commit comments

Comments
 (0)