Files
thailand-water/db/migrations/120_seed_sources.sql
T

41 lines
8.5 KiB
SQL

INSERT INTO source_registry (
source_id, provider, dataset, endpoint_type, base_url, native_unit, native_datum,
native_timezone, aggregation_interval, semantics_status, license,
commercial_use_status, expected_update_pattern, freshness_warn_after,
freshness_reject_after, priority, fallback_group, auth_required, parser_version,
enabled, notes
) VALUES
('hii_catalog','Hydro-Informatics Institute','Water-level catalog and historical archive discovery','CATALOG','https://data.go.th/th/dataset/water-level','m','MSL','Asia/Bangkok','10 minutes','VERIFIED','CC BY-NC (catalog-reported)','NON_COMMERCIAL_REPORTED','archive / batch',NULL,NULL,10,'stage',false,'1',true,'Metadata/archive discovery and historical calibration only; not live current-state data. Archive schema changes from February 2026.'),
('hii_legacy_daily','Hydro-Informatics Institute','Legacy daily water-level report','HTML','https://tiwrm.hii.or.th/DATA/REPORT/php/show_itcwater.php?sdate={date}',NULL,NULL,'Asia/Bangkok',NULL,'UNVERIFIED',NULL,'REVIEW_REQUIRED','historical fallback / discovery',NULL,NULL,40,'stage',false,'1',true,'Legacy endpoint is unstable; timeout is SOURCE_ERROR.'),
('hii_legacy_graph','Hydro-Informatics Institute','Legacy per-station water-level graph','HTML','https://tiwrm.hii.or.th/DATA/REPORT/php/itc_graph2.php?id1={legacy_id}%2C','m','MSL','Asia/Bangkok','10 minutes','UNVERIFIED',NULL,'REVIEW_REQUIRED','historical / current cross-check','30 minutes','2 hours',30,'stage',false,'1',true,'Do not accept numeric provider ID unless returned station code/name matches.'),
('hii_public_warning','Hydro-Informatics Institute','Public water-level warning page','HTML','https://tiwrm.hii.or.th/thaiwater_l5/public/telemetering/wl/warning',NULL,NULL,'Asia/Bangkok',NULL,'UNVERIFIED',NULL,'REVIEW_REQUIRED','current cross-check',NULL,NULL,30,'warning',false,'1',true,'Current/public cross-check only after timestamp and parse validation.'),
('thaiwater_v3','ThaiWater','Public water-level API candidate','JSON','https://api-v3.thaiwater.net',NULL,NULL,NULL,NULL,'UNVERIFIED',NULL,'REVIEW_REQUIRED',NULL,NULL,NULL,50,'stage',false,'1',false,'Disabled until runtime schema, terms and freshness are verified.'),
('dwr_ews_warnings','Department of Water Resources','EWS warning list','HTML','https://ews.dwr.go.th/ews/warn_list.php',NULL,NULL,'Asia/Bangkok',NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','5-10 minutes','30 minutes','2 hours',10,'warning',false,'1',true,'Cache/backoff is required; warning is never H/Q forcing.'),
('dwr_ews_station','Department of Water Resources','EWS station time series','HTML','https://ews.dwr.go.th/ews/list_temp.php?link={station_code}',NULL,NULL,'Asia/Bangkok',NULL,'UNVERIFIED',NULL,'REVIEW_REQUIRED','5-15 minutes','30 minutes','2 hours',15,'stage,rain',false,'1',true,'All timestamps require timezone-aware normalization; station identity must match.'),
('dwr_southwest','Department of Water Resources','Southwest telemetry portal discovery','HTML','https://tele-southwest.dwr.go.th/home/Index_HOME',NULL,NULL,'Asia/Bangkok',NULL,'UNVERIFIED',NULL,'REVIEW_REQUIRED',NULL,NULL,NULL,90,'stage',false,'1',true,'Optional discovery only; avoid double-counting observations from HII/RID.'),
('tmd_radar_discovery','Thai Meteorological Department','Radar and nationwide QPE product discovery','HTML','https://weather.tmd.go.th/chn.php',NULL,NULL,'UTC',NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','5-10 minutes','20 minutes','60 minutes',10,'rain',false,'1',true,'TMD page timestamps are UTC.'),
('tmd_qpe_ascii','Thai Meteorological Department','Dynamically discovered nationwide QPE ASCII','ZIP/ASCII','https://weather.tmd.go.th/composite/compositeQPE_VTBB_latest.asc.zip',NULL,NULL,'UTC',NULL,'UNVERIFIED',NULL,'REVIEW_REQUIRED','5-10 minutes','20 minutes','60 minutes',10,'rain',false,'1',true,'Always discover href from official radar page. Candidate URL previously returned 404; 404 is not zero rain.'),
('rid_dam','Royal Irrigation Department','Large dam public state','JSON','https://app.rid.go.th/reservoir/api/dam/public',NULL,NULL,'Asia/Bangkok','1 hour','PARTIAL','Source terms require review','REVIEW_REQUIRED','hourly','6 hours','48 hours',15,'reservoir',false,'1',true,'Storage fields are in million m3; inflow/outflow remain raw with null units and are excluded from physical mass balance.'),
('rid_reservoir','Royal Irrigation Department','Medium reservoir public state','JSON','https://app.rid.go.th/reservoir/api/reservoir/public',NULL,NULL,'Asia/Bangkok','1 hour','PARTIAL','Source terms require review','REVIEW_REQUIRED','hourly','6 hours','48 hours',15,'reservoir',false,'1',true,'Storage fields are in million m3; inflow/outflow remain raw with null units and are excluded from physical mass balance.'),
('navy_tide','Royal Thai Navy Hydrographic Department','Current-year MSL tide predictions','HTML/PDF','https://hydro.navy.mi.th/waterlaveltable','m','MSL when MSL edition selected','Asia/Bangkok','1 hour','PARTIAL',NULL,'REVIEW_REQUIRED','annual prediction table','30 days','365 days',20,'coastal_boundary',false,'1',true,'Predicted tide is FORECAST, not observed sea level; annual links must be discovered.'),
('gistda_flood','GISTDA','Satellite-derived flood features and map products','JSON/GeoJSON',NULL,NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','1-6 hours/API-limit aware','24 hours',NULL,20,'impact',true,'1',false,'Requires externally provisioned API base and key; empty response does not prove no flood.'),
('imerg','NASA GPM','IMERG Early precipitation','GIS/HTTP','https://jsimpsonhttps.pps.eosdis.nasa.gov/imerg/gis/',NULL,NULL,'UTC','30 minutes','PARTIAL',NULL,'REVIEW_REQUIRED','hourly availability','6 hours','12 hours',60,'cross_border_rain',true,'1',false,'Authentication may be required; not the sole 0-2h flash-flood trigger.'),
('hydrosheds','HydroSHEDS','Asia 3 arc-second conditioned DEM, flow direction and accumulation','STATIC_GIS','https://www.hydrosheds.org/hydrosheds-core-downloads',NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','static/versioned',NULL,NULL,30,'terrain',false,'1',true,'Retain originals; DEM/DIR/ACC required; 3s flat/coastal exact depth is restricted.'),
('hydrobasins','HydroSHEDS','Asia HydroBASINS levels 1-12','STATIC_VECTOR','https://www.hydrosheds.org/products/hydrobasins',NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','static/versioned',NULL,NULL,30,'network',false,'1',true,'Import full Asia topology and preserve source IDs/levels.'),
('hydrorivers','HydroSHEDS','Asia HydroRIVERS natural-river topology','STATIC_VECTOR','https://www.hydrosheds.org/products/hydrorivers',NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','static/versioned',NULL,NULL,30,'network',false,'1',true,'Natural-river skeleton only; no artificial canals inferred.'),
('ldd_landuse_admin','Land Development Department','Combined land use/soil administrative layer','ARCGIS REST','https://eis.ldd.go.th/ArcGIS/rest/services/LDD_SOIL_QUERY_WM/MapServer/5',NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','static/cache','180 days',NULL,40,'runoff_context',false,'1',true,'Layer native spatial reference EPSG:3857; preserve source attributes.'),
('ldd_landuse_subbasin','Land Development Department','Land use/soil subbasin layer','ARCGIS REST','https://eis.ldd.go.th/ArcGIS/rest/services/LDD_SOIL_QUERY_WM/MapServer/8',NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','static/cache','180 days',NULL,40,'runoff_context',false,'1',true,'Do not infer runoff from missing layer results.'),
('ldd_soil_query','Land Development Department','Point soil and land-use feature query','ARCGIS REST','https://eis.ldd.go.th/ArcGIS/rest/services/LDD_SOIL_WM/FeatureServer/6/query',NULL,NULL,NULL,NULL,'PARTIAL',NULL,'REVIEW_REQUIRED','on request','180 days',NULL,40,'runoff_context',false,'1',true,'WGS84 point input; preserve source CRS and fields.')
ON CONFLICT (source_id) DO UPDATE SET
provider=EXCLUDED.provider, dataset=EXCLUDED.dataset, endpoint_type=EXCLUDED.endpoint_type,
base_url=EXCLUDED.base_url, native_unit=EXCLUDED.native_unit, native_datum=EXCLUDED.native_datum,
native_timezone=EXCLUDED.native_timezone, aggregation_interval=EXCLUDED.aggregation_interval,
semantics_status=EXCLUDED.semantics_status, license=EXCLUDED.license,
commercial_use_status=EXCLUDED.commercial_use_status,
expected_update_pattern=EXCLUDED.expected_update_pattern,
freshness_warn_after=EXCLUDED.freshness_warn_after,
freshness_reject_after=EXCLUDED.freshness_reject_after, priority=EXCLUDED.priority,
fallback_group=EXCLUDED.fallback_group, auth_required=EXCLUDED.auth_required,
parser_version=EXCLUDED.parser_version, enabled=EXCLUDED.enabled,
notes=EXCLUDED.notes, updated_at=now();