@performant-software/geospatial 3.1.22-beta.12 → 3.1.22-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/index.cjs13.js +1 -1
  2. package/dist/index.cjs13.js.map +1 -1
  3. package/dist/index.cjs15.js +1 -1
  4. package/dist/index.cjs197.js +1 -1
  5. package/dist/index.cjs29.js +1 -1
  6. package/dist/index.cjs32.js +1 -1
  7. package/dist/index.cjs79.js +1 -743
  8. package/dist/index.cjs79.js.map +1 -1
  9. package/dist/index.cjs80.js +1 -1
  10. package/dist/index.cjs81.js +1 -1
  11. package/dist/index.cjs81.js.map +1 -1
  12. package/dist/index.cjs82.js +743 -1
  13. package/dist/index.cjs82.js.map +1 -1
  14. package/dist/index.cjs83.js +1 -9
  15. package/dist/index.cjs83.js.map +1 -1
  16. package/dist/index.cjs84.js +1 -17
  17. package/dist/index.cjs84.js.map +1 -1
  18. package/dist/index.cjs85.js +1 -1
  19. package/dist/index.cjs85.js.map +1 -1
  20. package/dist/index.cjs86.js +9 -1
  21. package/dist/index.cjs86.js.map +1 -1
  22. package/dist/index.cjs87.js +17 -1
  23. package/dist/index.cjs87.js.map +1 -1
  24. package/dist/index.es13.js +24 -23
  25. package/dist/index.es13.js.map +1 -1
  26. package/dist/index.es15.js +1 -1
  27. package/dist/index.es197.js +1 -1
  28. package/dist/index.es29.js +2 -2
  29. package/dist/index.es32.js +2 -2
  30. package/dist/index.es79.js +1954 -21313
  31. package/dist/index.es79.js.map +1 -1
  32. package/dist/index.es80.js +6 -2
  33. package/dist/index.es80.js.map +1 -1
  34. package/dist/index.es81.js +2 -8
  35. package/dist/index.es81.js.map +1 -1
  36. package/dist/index.es82.js +21352 -2
  37. package/dist/index.es82.js.map +1 -1
  38. package/dist/index.es83.js +2 -26
  39. package/dist/index.es83.js.map +1 -1
  40. package/dist/index.es84.js +7 -588
  41. package/dist/index.es84.js.map +1 -1
  42. package/dist/index.es85.js +2 -1993
  43. package/dist/index.es85.js.map +1 -1
  44. package/dist/index.es86.js +25 -5
  45. package/dist/index.es86.js.map +1 -1
  46. package/dist/index.es87.js +589 -2
  47. package/dist/index.es87.js.map +1 -1
  48. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";const C=require("./index.cjs68.js"),q=require("./index.cjs69.js"),L=require("./index.cjs70.js"),_=require("./index.cjs71.js"),$=require("./index.cjs72.js"),M=require("./index.cjs73.js"),v=require("./index.cjs74.js"),A=require("./index.cjs75.js"),B=require("./index.cjs76.js"),I=require("./index.cjs77.js"),o=require("./index.cjs67.js"),G=require("./index.cjs78.js"),y=require("./index.cjs36.js");require("./index.cjs37.js");require("./index.cjs38.js");require("./index.cjs39.js");require("./index.cjs40.js");require("./index.cjs41.js");require("./index.cjs42.js");require("./index.cjs43.js");require("./index.cjs44.js");require("./index.cjs45.js");require("./index.cjs46.js");require("./index.cjs47.js");require("./index.cjs48.js");require("./index.cjs49.js");require("./index.cjs50.js");require("./index.cjs51.js");require("./index.cjs52.js");require("./index.cjs53.js");require("./index.cjs54.js");require("./index.cjs55.js");require("./index.cjs56.js");require("./index.cjs57.js");require("./index.cjs58.js");require("./index.cjs59.js");require("./index.cjs60.js");require("./index.cjs61.js");require("./index.cjs62.js");require("./index.cjs63.js");const T=-90,U=90,F=-180,P=180,d=(e,n)=>A.default(e.coordinates,n,{units:"kilometers",steps:32}),D=(e,n)=>{if(e.geometry?.type==="FeatureCollection"){let r=[];for(const t of e.geometry.features)if(t.geometry?.type==="Point"){const{geometry:i,type:u}=d(t.geometry,n);r.push({...t,geometry:i,type:u})}return o.featureCollection(r)}else{if(e.geometry?.type==="GeometryCollection")return o.featureCollection(e.geometry.geometries.map(r=>r.type==="Point"?d(r,n):o.feature(r)));if(e.geometry?.type==="Point"){const{geometry:r,type:t}=d(e.geometry,n);return{...e,geometry:r,type:t}}}return e},E=(e,n,r={})=>{const t=new C.WarpedMapLayer(n);e.addLayer(t),r.url?t.addGeoreferenceAnnotationByUrl(r.url):r.manifest&&t.addGeoreferenceAnnotation(r.manifest),r.opacity&&t.setOpacity(r.opacity)},N=(e,n=null)=>{const r=q.bbox(e);if(!f(r))return null;const t=L.bboxPolygon(r);let i;return n?i=M.buffer(t,n,{units:"miles"}):i=t,q.bbox(i)},h=(e,n)=>e&&e.removeLayer(n),O=(e,n,r,t)=>{const i={id:e.record_id,ccode:[],title:e.name,uuid:e.uuid,record_id:e.record_id,name:e.name,names:e.names?.map(s=>({toponym:s})),type:e.type,items:[n],url:e.url,originalProperties:t||{}},u=parseInt(e.record_id,10);return o.feature(r,i,{id:u})},w=e=>o.featureCollection(e),f=e=>y.every(e,y.isFinite),S=e=>{let n=!1;if(e){const[r,t]=e;n=r>=T&&r<=U&&t>=F&&t<=P}return n},X=(e,n={})=>{const{curvature:r=-.2}=n;return o.featureCollection(e.map((t,i)=>{const u=v.centroid(t).geometry.coordinates,s=u[0],c=u[1],p=I.distance(s,c),g=G.midpoint(s,c),a=_.bearing(s,c),m=a+90>180?a+90-360:a+90,x=B.destination(g,p*r,m),b=o.lineString([s,x.geometry.coordinates,c]),l=$.bezierSpline(b);return l.properties={...l.properties,index:i},l}))},k={addGeoreferenceLayer:E,toCertaintyCircle:D,getBoundingBox:N,removeLayer:h,toArcs:X,toFeature:O,toFeatureCollection:w,validateBoundingBox:f,validateCoordinates:S};module.exports=k;
1
+ "use strict";const C=require("./index.cjs68.js"),q=require("./index.cjs69.js"),L=require("./index.cjs70.js"),_=require("./index.cjs71.js"),$=require("./index.cjs72.js"),M=require("./index.cjs73.js"),v=require("./index.cjs74.js"),A=require("./index.cjs75.js"),B=require("./index.cjs76.js"),I=require("./index.cjs77.js"),s=require("./index.cjs67.js"),F=require("./index.cjs78.js"),y=require("./index.cjs36.js");require("./index.cjs37.js");require("./index.cjs38.js");require("./index.cjs39.js");require("./index.cjs40.js");require("./index.cjs41.js");require("./index.cjs42.js");require("./index.cjs43.js");require("./index.cjs44.js");require("./index.cjs45.js");require("./index.cjs46.js");require("./index.cjs47.js");require("./index.cjs48.js");require("./index.cjs49.js");require("./index.cjs50.js");require("./index.cjs51.js");require("./index.cjs52.js");require("./index.cjs53.js");require("./index.cjs54.js");require("./index.cjs55.js");require("./index.cjs56.js");require("./index.cjs57.js");require("./index.cjs58.js");require("./index.cjs59.js");require("./index.cjs60.js");require("./index.cjs61.js");require("./index.cjs62.js");require("./index.cjs63.js");const G=-90,T=90,U=-180,h=180,d=(e,n)=>A.default(e.coordinates,n,{units:"kilometers",steps:32}),P=(e,n)=>{if(e.geometry?.type==="FeatureCollection"){let r=[];for(const t of e.geometry.features)if(t.geometry?.type==="Point"){const{geometry:o,type:i}=d(t.geometry,n);r.push({...t,geometry:o,type:i})}return s.featureCollection(r)}else{if(e.geometry?.type==="GeometryCollection")return s.featureCollection(e.geometry.geometries.map(r=>r.type==="Point"?d(r,n):s.feature(r)));if(e.geometry?.type==="Point"){const{geometry:r,type:t}=d(e.geometry,n);return{...e,geometry:r,type:t}}}return e},D=(e,n,r={})=>{const t=new C.WarpedMapLayer(n);e.addLayer(t),r.url?t.addGeoreferenceAnnotationByUrl(r.url):r.manifest&&t.addGeoreferenceAnnotation(r.manifest),r.opacity&&t.setOpacity(r.opacity)},E=(e,n=null)=>{const r=q.bbox(e);if(!f(r))return null;const t=L.bboxPolygon(r);let o;return n?o=M.buffer(t,n,{units:"miles"}):o=t,q.bbox(o)},N=(e,n)=>e&&e.removeLayer(n),O=(e,n,r,t)=>{const o={id:e.record_id,ccode:[],title:e.name,uuid:e.uuid,record_id:e.record_id,name:e.name,names:e.names?.map(u=>({toponym:u})),type:e.type,items:[n],url:e.url,originalProperties:t||{}},i=parseInt(e.record_id,10);return s.feature(r,o,{id:i})},w=e=>s.featureCollection(e),f=e=>y.every(e,y.isFinite),S=e=>{let n=!1;if(e){const[r,t]=e;n=r>=G&&r<=T&&t>=U&&t<=h}return n},X=(e,n={})=>{const{curvature:r=-.2}=n,t=e.map(i=>v.centroid(i).geometry.coordinates),o=[];for(let i=0;i<t.length-1;i+=1){const u=t[i],c=t[i+1],p=I.distance(u,c),g=F.midpoint(u,c),a=_.bearing(u,c),m=a+90>180?a+90-360:a+90,x=B.destination(g,p*r,m),b=s.lineString([u,x.geometry.coordinates,c]),l=$.bezierSpline(b);l.properties={...l.properties,index:i},o.push(l)}return s.featureCollection(o)},k={addGeoreferenceLayer:D,toCertaintyCircle:P,getBoundingBox:E,removeLayer:N,toArcs:X,toFeature:O,toFeatureCollection:w,validateBoundingBox:f,validateCoordinates:S};module.exports=k;
2
2
  //# sourceMappingURL=index.cjs13.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs13.js","sources":["../src/utils/Map.js"],"sourcesContent":["// @flow\n\nimport { WarpedMapLayer } from '@allmaps/maplibre';\nimport {\n bbox,\n bboxPolygon,\n bearing,\n bezierSpline,\n buffer,\n centroid,\n destination,\n distance,\n feature,\n featureCollection,\n lineString,\n midpoint\n} from '@turf/turf';\nimport _ from 'underscore';\nimport circle from '@turf/circle';\n\nconst MIN_LATITUDE = -90;\nconst MAX_LATITUDE = 90;\nconst MIN_LONGITUDE = -180;\nconst MAX_LONGITUDE = 180;\n\n/**\n * Returns a GeoJSON circle feature with the given center point and radius.\n * @param point - The center point of the circle.\n * @param radius - The radius of the circle in kilometers.\n * @returns {Feature<Geometry, Properties>} - The GeoJSON circle feature.\n */\nconst buildCircle = (point, radius) => (\n circle(point.coordinates, radius, { units: 'kilometers', steps: 32 })\n);\n\nconst toCertaintyCircle = (item, radius: number) => {\n if (item.geometry?.type === 'FeatureCollection') {\n let children = [];\n\n for (const childFeature of item.geometry.features) {\n if (childFeature.geometry?.type === 'Point') {\n const { geometry, type } = buildCircle(childFeature.geometry, radius);\n children.push({\n ...childFeature,\n geometry,\n type\n });\n }\n }\n\n return featureCollection(children);\n } else if (item.geometry?.type === 'GeometryCollection') {\n return featureCollection(item.geometry.geometries.map((geometry) => geometry.type === 'Point'\n ? buildCircle(geometry, radius)\n : feature(geometry)));\n } else if (item.geometry?.type === 'Point') {\n const { geometry, type } = buildCircle(item.geometry, radius);\n return {\n ...item,\n geometry,\n type\n };\n }\n\n return item;\n};\n\n/**\n * Adds the geo-referenced image layer to the passed map.\n *\n * @param map\n * @param layerId\n * @param options\n */\nconst addGeoreferenceLayer = (map, layerId, options = {}) => {\n const warpedMapLayer = new WarpedMapLayer(layerId);\n map.addLayer(warpedMapLayer);\n\n if (options.url) {\n warpedMapLayer.addGeoreferenceAnnotationByUrl(options.url);\n } else if (options.manifest) {\n warpedMapLayer.addGeoreferenceAnnotation(options.manifest);\n }\n\n if (options.opacity) {\n warpedMapLayer.setOpacity(options.opacity);\n }\n};\n\n/**\n * Returns a bounding box for the passed geometry (with optional buffer).\n *\n * @param data\n * @param bufferDistance\n *\n * @returns {BBox}\n */\nconst getBoundingBox = (data, bufferDistance = null) => {\n // Convert the GeoJSON into a bounding box\n const box = bbox(data);\n\n if (!validateBoundingBox(box)) {\n return null;\n }\n\n // Convert the bounding box to a polygon\n const polygon = bboxPolygon(box);\n\n // Create a buffer around the polygon (if a distance is provided)\n let polygonBuffer;\n\n if (bufferDistance) {\n polygonBuffer = buffer(polygon, bufferDistance, { units: 'miles' });\n } else {\n polygonBuffer = polygon;\n }\n\n // Convert the buffer to a bounding box\n return bbox(polygonBuffer);\n};\n\n/**\n * Removes a layer from the passed map.\n *\n * @param map\n * @param layerId\n *\n * @returns {*}\n */\nconst removeLayer = (map, layerId) => map && map.removeLayer(layerId);\n\n/**\n * Wraps the passed record in a feature.\n *\n * @param record\n * @param item\n * @param geometry\n * @param originalProperties\n *\n * @returns {Feature<Geometry, {\n * id: *,\n * ccode: [],\n * title: *,\n * uuid: *,\n * record_id: *,\n * name: *,\n * names: *,\n * type: *,\n * items: [*],\n * url: *\n * }>}\n */\nconst toFeature = (record: any, item: any, geometry: any, originalProperties?: any) => {\n const properties = {\n id: record.record_id,\n ccode: [],\n title: record.name,\n uuid: record.uuid,\n record_id: record.record_id,\n name: record.name,\n names: record.names?.map((toponym: string) => ({ toponym })),\n type: record.type,\n items: [item],\n url: record.url,\n originalProperties: originalProperties || {}\n };\n\n const id = parseInt(record.record_id, 10);\n return feature(geometry, properties, { id });\n};\n\n/**\n * Returns a feature collection for the passed set of features.\n *\n * @param features\n *\n * @returns {FeatureCollection<Geometry, GeoJsonProperties>}\n */\nconst toFeatureCollection = (features: Array<any>) => featureCollection(features);\n\n/**\n * Validates that the passed bounding box contains finite coordinates.\n *\n * @param boundingBox\n *\n * @returns {*}\n */\nconst validateBoundingBox = (boundingBox: Array<number>) => _.every(boundingBox, _.isFinite);\n\n/**\n * Returns true if the passed coordinates are valid.\n *\n * @param coordinates\n *\n * @returns {boolean}\n */\nconst validateCoordinates = (coordinates) => {\n let valid = false;\n\n if (coordinates) {\n const [latitude, longitude] = coordinates;\n\n valid = latitude >= MIN_LATITUDE\n && latitude <= MAX_LATITUDE\n && longitude >= MIN_LONGITUDE\n && longitude <= MAX_LONGITUDE;\n }\n\n return valid;\n};\n\n/**\n * Returns a GeoJSON FeatureCollection of LineStrings (arcs) for the passed coordinates.\n *\n * @param features\n * @param options\n *\n * @returns {FeatureCollection<LineString, GeoJsonProperties>}\n */\nconst toArcs = (features, options = {}) => {\n const { curvature = -0.2 } = options;\n\n return featureCollection(features.map((feature, idx) => {\n const coordinates = centroid(feature).geometry.coordinates;\n const start = coordinates[0];\n const end = coordinates[1];\n\n const d = distance(start, end);\n const m = midpoint(start, end);\n const b = bearing(start, end);\n\n const offsetBearing = b + 90 > 180 ? b + 90 - 360 : b + 90;\n const dest = destination(m, d * curvature, offsetBearing);\n\n const line = lineString([start, dest.geometry.coordinates, end]);\n const arc = bezierSpline(line);\n\n arc.properties = {\n ...arc.properties,\n index: idx\n };\n\n return arc;\n }));\n};\n\nexport default {\n addGeoreferenceLayer,\n toCertaintyCircle,\n getBoundingBox,\n removeLayer,\n toArcs,\n toFeature,\n toFeatureCollection,\n validateBoundingBox,\n validateCoordinates\n};\n"],"names":["MIN_LATITUDE","MAX_LATITUDE","MIN_LONGITUDE","MAX_LONGITUDE","buildCircle","point","radius","circle","toCertaintyCircle","item","children","childFeature","geometry","type","featureCollection","feature","addGeoreferenceLayer","map","layerId","options","warpedMapLayer","WarpedMapLayer","getBoundingBox","data","bufferDistance","box","bbox","validateBoundingBox","polygon","bboxPolygon","polygonBuffer","buffer","removeLayer","toFeature","record","originalProperties","properties","toponym","id","toFeatureCollection","features","boundingBox","_","validateCoordinates","coordinates","valid","latitude","longitude","toArcs","curvature","idx","centroid","start","end","d","distance","m","midpoint","b","bearing","offsetBearing","dest","destination","line","lineString","arc","bezierSpline","MapUtils"],"mappings":"6oCAoBA,MAAMA,EAAe,IACfC,EAAe,GACfC,EAAgB,KAChBC,EAAgB,IAQhBC,EAAc,CAACC,EAAOC,IAC1BC,EAAAA,QAAOF,EAAM,YAAaC,EAAQ,CAAE,MAAO,aAAc,MAAO,GAAI,EAGhEE,EAAoB,CAACC,EAAMH,IAAmB,CAClD,GAAIG,EAAK,UAAU,OAAS,oBAAqB,CAC/C,IAAIC,EAAW,CAAA,EAEf,UAAWC,KAAgBF,EAAK,SAAS,SACvC,GAAIE,EAAa,UAAU,OAAS,QAAS,CAC3C,KAAM,CAAE,SAAAC,EAAU,KAAAC,CAAA,EAAST,EAAYO,EAAa,SAAUL,CAAM,EACpEI,EAAS,KAAK,CACZ,GAAGC,EACH,SAAAC,EACA,KAAAC,CAAA,CACD,CACH,CAGF,OAAOC,EAAAA,kBAAkBJ,CAAQ,CACnC,KAAA,IAAWD,EAAK,UAAU,OAAS,qBACjC,OAAOK,EAAAA,kBAAkBL,EAAK,SAAS,WAAW,IAAKG,GAAaA,EAAS,OAAS,QAClFR,EAAYQ,EAAUN,CAAM,EAC5BS,EAAAA,QAAQH,CAAQ,CAAC,CAAC,EACxB,GAAWH,EAAK,UAAU,OAAS,QAAS,CAC1C,KAAM,CAAE,SAAAG,EAAU,KAAAC,CAAA,EAAST,EAAYK,EAAK,SAAUH,CAAM,EAC5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eb,EAAuBc,GAA+BC,EAAE,MAAMD,EAAaC,EAAE,QAAQ,EASrFC,EAAuBC,GAAgB,CAC3C,IAAIC,EAAQ,GAEZ,GAAID,EAAa,CACf,KAAM,CAACE,EAAUC,CAAS,EAAIH,EAE9BC,EAAQC,GAAY9C,GACf8C,GAAY7C,GACZ8C,GAAa7C,GACb6C,GAAa5C,CACpB,CAEA,OAAO0C,CACT,EAUMG,EAAS,CAACR,EAAUrB,EAAU,KAAO,CACzC,KAAM,CAAE,UAAA8B,EAAY,GAAA,EAAS9B,EAE7B,OAAOL,EAAAA,kBAAkB0B,EAAS,IAAI,CAACzB,EAASmC,IAAQ,CACtD,MAAMN,EAAcO,EAAAA,SAASpC,CAAO,EAAE,SAAS,YACzCqC,EAAQR,EAAY,CAAC,EACrBS,EAAMT,EAAY,CAAC,EAEnBU,EAAIC,EAAAA,SAASH,EAAOC,CAAG,EACvBG,EAAIC,EAAAA,SAASL,EAAOC,CAAG,EACvBK,EAAIC,EAAAA,QAAQP,EAAOC,CAAG,EAEtBO,EAAgBF,EAAI,GAAK,IAAMA,EAAI,GAAK,IAAMA,EAAI,GAClDG,EAAOC,EAAAA,YAAYN,EAAGF,EAAIL,EAAWW,CAAa,EAElDG,EAAOC,EAAAA,WAAW,CAACZ,EAAOS,EAAK,SAAS,YAAaR,CAAG,CAAC,EACzDY,EAAMC,EAAAA,aAAaH,CAAI,EAE7B,OAAAE,EAAI,WAAa,CACf,GAAGA,EAAI,WACP,MAAOf,CAAA,EAGFe,CACT,CAAC,CAAC,CACJ,EAEAE,EAAe,CACb,qBAAAnD,EACA,kBAAAR,EACA,eAAAc,EACA,YAAAU,EACA,OAAAgB,EACA,UAAAf,EACA,oBAAAM,EACA,oBAAAZ,EACA,oBAAAgB,CACF"}
1
+ {"version":3,"file":"index.cjs13.js","sources":["../src/utils/Map.js"],"sourcesContent":["// @flow\n\nimport { WarpedMapLayer } from '@allmaps/maplibre';\nimport {\n bbox,\n bboxPolygon,\n bearing,\n bezierSpline,\n buffer,\n centroid,\n destination,\n distance,\n feature,\n featureCollection,\n lineString,\n midpoint\n} from '@turf/turf';\nimport _ from 'underscore';\nimport circle from '@turf/circle';\n\nconst MIN_LATITUDE = -90;\nconst MAX_LATITUDE = 90;\nconst MIN_LONGITUDE = -180;\nconst MAX_LONGITUDE = 180;\n\n/**\n * Returns a GeoJSON circle feature with the given center point and radius.\n * @param point - The center point of the circle.\n * @param radius - The radius of the circle in kilometers.\n * @returns {Feature<Geometry, Properties>} - The GeoJSON circle feature.\n */\nconst buildCircle = (point, radius) => (\n circle(point.coordinates, radius, { units: 'kilometers', steps: 32 })\n);\n\nconst toCertaintyCircle = (item, radius: number) => {\n if (item.geometry?.type === 'FeatureCollection') {\n let children = [];\n\n for (const childFeature of item.geometry.features) {\n if (childFeature.geometry?.type === 'Point') {\n const { geometry, type } = buildCircle(childFeature.geometry, radius);\n children.push({\n ...childFeature,\n geometry,\n type\n });\n }\n }\n\n return featureCollection(children);\n } else if (item.geometry?.type === 'GeometryCollection') {\n return featureCollection(item.geometry.geometries.map((geometry) => geometry.type === 'Point'\n ? buildCircle(geometry, radius)\n : feature(geometry)));\n } else if (item.geometry?.type === 'Point') {\n const { geometry, type } = buildCircle(item.geometry, radius);\n return {\n ...item,\n geometry,\n type\n };\n }\n\n return item;\n};\n\n/**\n * Adds the geo-referenced image layer to the passed map.\n *\n * @param map\n * @param layerId\n * @param options\n */\nconst addGeoreferenceLayer = (map, layerId, options = {}) => {\n const warpedMapLayer = new WarpedMapLayer(layerId);\n map.addLayer(warpedMapLayer);\n\n if (options.url) {\n warpedMapLayer.addGeoreferenceAnnotationByUrl(options.url);\n } else if (options.manifest) {\n warpedMapLayer.addGeoreferenceAnnotation(options.manifest);\n }\n\n if (options.opacity) {\n warpedMapLayer.setOpacity(options.opacity);\n }\n};\n\n/**\n * Returns a bounding box for the passed geometry (with optional buffer).\n *\n * @param data\n * @param bufferDistance\n *\n * @returns {BBox}\n */\nconst getBoundingBox = (data, bufferDistance = null) => {\n // Convert the GeoJSON into a bounding box\n const box = bbox(data);\n\n if (!validateBoundingBox(box)) {\n return null;\n }\n\n // Convert the bounding box to a polygon\n const polygon = bboxPolygon(box);\n\n // Create a buffer around the polygon (if a distance is provided)\n let polygonBuffer;\n\n if (bufferDistance) {\n polygonBuffer = buffer(polygon, bufferDistance, { units: 'miles' });\n } else {\n polygonBuffer = polygon;\n }\n\n // Convert the buffer to a bounding box\n return bbox(polygonBuffer);\n};\n\n/**\n * Removes a layer from the passed map.\n *\n * @param map\n * @param layerId\n *\n * @returns {*}\n */\nconst removeLayer = (map, layerId) => map && map.removeLayer(layerId);\n\n/**\n * Wraps the passed record in a feature.\n *\n * @param record\n * @param item\n * @param geometry\n * @param originalProperties\n *\n * @returns {Feature<Geometry, {\n * id: *,\n * ccode: [],\n * title: *,\n * uuid: *,\n * record_id: *,\n * name: *,\n * names: *,\n * type: *,\n * items: [*],\n * url: *\n * }>}\n */\nconst toFeature = (record: any, item: any, geometry: any, originalProperties?: any) => {\n const properties = {\n id: record.record_id,\n ccode: [],\n title: record.name,\n uuid: record.uuid,\n record_id: record.record_id,\n name: record.name,\n names: record.names?.map((toponym: string) => ({ toponym })),\n type: record.type,\n items: [item],\n url: record.url,\n originalProperties: originalProperties || {}\n };\n\n const id = parseInt(record.record_id, 10);\n return feature(geometry, properties, { id });\n};\n\n/**\n * Returns a feature collection for the passed set of features.\n *\n * @param features\n *\n * @returns {FeatureCollection<Geometry, GeoJsonProperties>}\n */\nconst toFeatureCollection = (features: Array<any>) => featureCollection(features);\n\n/**\n * Validates that the passed bounding box contains finite coordinates.\n *\n * @param boundingBox\n *\n * @returns {*}\n */\nconst validateBoundingBox = (boundingBox: Array<number>) => _.every(boundingBox, _.isFinite);\n\n/**\n * Returns true if the passed coordinates are valid.\n *\n * @param coordinates\n *\n * @returns {boolean}\n */\nconst validateCoordinates = (coordinates) => {\n let valid = false;\n\n if (coordinates) {\n const [latitude, longitude] = coordinates;\n\n valid = latitude >= MIN_LATITUDE\n && latitude <= MAX_LATITUDE\n && longitude >= MIN_LONGITUDE\n && longitude <= MAX_LONGITUDE;\n }\n\n return valid;\n};\n\n/**\n * Returns a GeoJSON FeatureCollection of LineStrings (arcs) for the passed coordinates.\n *\n * @param features\n * @param options\n *\n * @returns {FeatureCollection<LineString, GeoJsonProperties>}\n */\nconst toArcs = (features, options = {}) => {\n const { curvature = -0.2 } = options;\n\n const coordinates = features.map(feature => centroid(feature).geometry.coordinates);\n\n const arcFeatures = [];\n\n for (let i = 0; i < coordinates.length - 1; i += 1) {\n const start = coordinates[i];\n const end = coordinates[i + 1];\n\n const d = distance(start, end);\n const m = midpoint(start, end);\n const b = bearing(start, end);\n\n const offsetBearing = b + 90 > 180 ? b + 90 - 360 : b + 90;\n const dest = destination(m, d * curvature, offsetBearing);\n\n const line = lineString([start, dest.geometry.coordinates, end]);\n const arc = bezierSpline(line);\n\n arc.properties = {\n ...arc.properties,\n index: i\n };\n\n arcFeatures.push(arc);\n }\n\n return featureCollection(arcFeatures);\n};\n\nexport default {\n addGeoreferenceLayer,\n toCertaintyCircle,\n getBoundingBox,\n removeLayer,\n toArcs,\n toFeature,\n toFeatureCollection,\n validateBoundingBox,\n validateCoordinates\n};\n"],"names":["MIN_LATITUDE","MAX_LATITUDE","MIN_LONGITUDE","MAX_LONGITUDE","buildCircle","point","radius","circle","toCertaintyCircle","item","children","childFeature","geometry","type","featureCollection","feature","addGeoreferenceLayer","map","layerId","options","warpedMapLayer","WarpedMapLayer","getBoundingBox","data","bufferDistance","box","bbox","validateBoundingBox","polygon","bboxPolygon","polygonBuffer","buffer","removeLayer","toFeature","record","originalProperties","properties","toponym","id","toFeatureCollection","features","boundingBox","_","validateCoordinates","coordinates","valid","latitude","longitude","toArcs","curvature","centroid","arcFeatures","start","end","d","distance","m","midpoint","b","bearing","offsetBearing","dest","destination","line","lineString","arc","bezierSpline","MapUtils"],"mappings":"6oCAoBA,MAAMA,EAAe,IACfC,EAAe,GACfC,EAAgB,K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,EAAI,EAAG,EAAIP,EAAY,OAAS,EAAG,GAAK,EAAG,CAClD,MAAMQ,EAAQR,EAAY,CAAC,EACrBS,EAAMT,EAAY,EAAI,CAAC,EAEvBU,EAAIC,EAAAA,SAASH,EAAOC,CAAG,EACvBG,EAAIC,EAAAA,SAASL,EAAOC,CAAG,EACvBK,EAAIC,EAAAA,QAAQP,EAAOC,CAAG,EAEtBO,EAAgBF,EAAI,GAAK,IAAMA,EAAI,GAAK,IAAMA,EAAI,GAClDG,EAAOC,EAAAA,YAAYN,EAAGF,EAAIL,EAAWW,CAAa,EAElDG,EAAOC,EAAAA,WAAW,CAACZ,EAAOS,EAAK,SAAS,YAAaR,CAAG,CAAC,EACzDY,EAAMC,EAAAA,aAAaH,CAAI,EAE7BE,EAAI,WAAa,CACf,GAAGA,EAAI,WACP,MAAO,CAAA,EAGTd,EAAY,KAAKc,CAAG,CACtB,CAEA,OAAOnD,EAAAA,kBAAkBqC,CAAW,CACtC,EAEAgB,EAAe,CACb,qBAAAnD,EACA,kBAAAR,EACA,eAAAc,EACA,YAAAU,EACA,OAAAgB,EACA,UAAAf,EACA,oBAAAM,EACA,oBAAAZ,EACA,oBAAAgB,CACF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index.cjs81.js");var t=e.__require();exports.jsxRuntimeExports=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index.cjs84.js");var t=e.__require();exports.jsxRuntimeExports=t;
2
2
  //# sourceMappingURL=index.cjs15.js.map
@@ -1,2 +1,2 @@
1
- "use strict";const s=require("./index.cjs86.js"),r=require("./index.cjs245.js");var t=r.__require();const e=s.getDefaultExportFromCjs(t);module.exports=e;
1
+ "use strict";const s=require("./index.cjs80.js"),r=require("./index.cjs245.js");var t=r.__require();const e=s.getDefaultExportFromCjs(t);module.exports=e;
2
2
  //# sourceMappingURL=index.cjs197.js.map
@@ -1,2 +1,2 @@
1
- "use strict";const r=require("./index.cjs86.js"),e=require("./index.cjs85.js");var o=e.__require();const s=r.getDefaultExportFromCjs(o);module.exports=s;
1
+ "use strict";const r=require("./index.cjs80.js"),e=require("./index.cjs79.js");var o=e.__require();const s=r.getDefaultExportFromCjs(o);module.exports=s;
2
2
  //# sourceMappingURL=index.cjs29.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./index.cjs86.js"),u=require("./index.cjs79.js");function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const l=Object.getOwnPropertyDescriptor(e,r);l&&Object.defineProperty(t,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var i=u.__require();const s=a.getDefaultExportFromCjs(i),p=c({__proto__:null,default:s},[i]);exports.Li=p;exports.default=s;exports.maplibreGlExports=i;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./index.cjs80.js"),u=require("./index.cjs82.js");function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const l=Object.getOwnPropertyDescriptor(e,r);l&&Object.defineProperty(t,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var i=u.__require();const s=a.getDefaultExportFromCjs(i),p=c({__proto__:null,default:s},[i]);exports.Li=p;exports.default=s;exports.maplibreGlExports=i;
2
2
  //# sourceMappingURL=index.cjs32.js.map