Skip to content

Commit

Permalink
allow use_device_pixel_ratio setting on arcgis raster tile sources
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Dec 11, 2023
1 parent 0cc4f9a commit 321181c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
79 changes: 79 additions & 0 deletions packages/api/migrations/committed/000283.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
--! Previous: sha1:6284aa014c05f12ad1b5920e5686ba8fa4be3ad4
--! Hash: sha1:02e45756b70820a4a7dbf64d7732f24c952bfcd9

-- Enter migration here
CREATE OR REPLACE FUNCTION public.before_insert_or_update_data_sources_trigger() RETURNS trigger
LANGUAGE plpgsql
AS $$
declare
bucket_id text;
begin
if new.minzoom is not null and (new.type != 'vector' and new.type != 'raster' and new.type != 'raster-dem' and new.type != 'seasketch-mvt' and new.type != 'seasketch-raster' and new.type != 'arcgis-raster-tiles' ) then
raise 'minzoom may only be set for tiled sources (vector, raster, raster-dem)';
end if;
if new.coordinates is null and (new.type = 'video' or new.type = 'image') then
raise 'coordinates must be set on image and video sources';
end if;
if new.coordinates is not null and (new.type != 'video' and new.type != 'image') then
raise 'coordinates property can only be set on image and video sources';
end if;
if new.maxzoom is not null and (new.type = 'image' or new.type = 'video') then
raise 'maxzoom cannot be set for image and video sources';
end if;
if new.url is null and (new.type = 'geojson' or new.type = 'image' or new.type = 'arcgis-dynamic-mapserver' or new.type = 'arcgis-vector' or new.type = 'seasketch-mvt') then
raise 'url must be set for "%" sources', (new.type);
end if;
if new.scheme is not null and (new.type != 'raster' and new.type != 'raster-dem' and new.type != 'vector' and new.type != 'seasketch-mvt') then
raise 'scheme property is not allowed for "%" sources', (new.type);
end if;
if new.tiles is not null and (new.type != 'raster' and new.type != 'raster-dem' and new.type != 'vector' and new.type != 'seasketch-vector') then
raise 'tiles property is not allowed for "%" sources', (new.type);
end if;
if new.encoding is not null and new.type != 'raster-dem' then
raise 'encoding property only allowed on raster-dem sources';
end if;
if new.tile_size is not null and (new.type != 'raster' and new.type != 'raster-dem' and new.type != 'vector' and new.type != 'seasketch-mvt' and new.type != 'seasketch-raster') then
raise 'tile_size property is not allowed for "%" sources', (new.type);
end if;
if (new.type != 'geojson' and new.type != 'seasketch-vector') and (new.buffer is not null or new.cluster is not null or new.cluster_max_zoom is not null or new.cluster_properties is not null or new.cluster_radius is not null or new.generate_id is not null or new.line_metrics is not null or new.promote_id is not null or new.tolerance is not null) then
raise 'geojson props such as buffer, cluster, generate_id, etc not allowed on % sources', (new.type);
end if;
if (new.byte_length is not null and new.type != 'seasketch-vector' and new.type != 'seasketch-mvt' and new.type != 'seasketch-raster') then
raise 'byte_length can only be set on seasketch-vector, seasketch_mvt and seasketch-raster sources';
end if;
if (new.type = 'seasketch-vector' and new.type != 'seasketch-mvt' and new.byte_length is null) then
raise 'seasketch-vector and mvt sources must have byte_length set to an approximate value';
end if;
if new.urls is not null and new.type != 'video' then
raise 'urls property not allowed on % sources', (new.type);
end if;
if new.query_parameters is not null and (new.type != 'arcgis-vector' and new.type != 'arcgis-dynamic-mapserver') then
raise 'query_parameters property not allowed on % sources', (new.type);
end if;
if new.use_device_pixel_ratio is not null and (new.type != 'arcgis-dynamic-mapserver' and new.type != 'arcgis-raster-tiles') then
raise 'use_device_pixel_ratio property not allowed on % sources', (new.type);
end if;
if new.import_type is not null and new.type != 'seasketch-vector' and new.type != 'seasketch-mvt' and new.type != 'seasketch-raster' then
raise 'import_type property is only allowed for seasketch-vector, seasketch-mvt, and seasketch-raster sources';
end if;
if new.import_type is null and (new.type = 'seasketch-vector' or new.type = 'seasketch-mvt') then
raise 'import_type property is required for seasketch-vector sources';
end if;
if new.original_source_url is not null and new.type != 'seasketch-vector' then
raise 'original_source_url may only be set on seasketch-vector sources';
end if;
if new.enhanced_security is not null and new.type != 'seasketch-vector' then
raise 'enhanced_security may only be set on seasketch-vector sources';
end if;
if old is null and new.type = 'seasketch-vector' then
if new.bucket_id is null then
new.bucket_id = (select data_sources_bucket_id from projects where id = new.project_id);
end if;
if new.object_key is null then
new.object_key = (select gen_random_uuid());
end if;
new.tiles = null;
end if;
return new;
end;
$$;
2 changes: 1 addition & 1 deletion packages/api/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3089,7 +3089,7 @@ CREATE FUNCTION public.before_insert_or_update_data_sources_trigger() RETURNS tr
if new.query_parameters is not null and (new.type != 'arcgis-vector' and new.type != 'arcgis-dynamic-mapserver') then
raise 'query_parameters property not allowed on % sources', (new.type);
end if;
if new.use_device_pixel_ratio is not null and new.type != 'arcgis-dynamic-mapserver' then
if new.use_device_pixel_ratio is not null and (new.type != 'arcgis-dynamic-mapserver' and new.type != 'arcgis-raster-tiles') then
raise 'use_device_pixel_ratio property not allowed on % sources', (new.type);
end if;
if new.import_type is not null and new.type != 'seasketch-vector' and new.type != 'seasketch-mvt' and new.type != 'seasketch-raster' then
Expand Down

0 comments on commit 321181c

Please sign in to comment.