@corva/ui 3.70.0-5 → 3.70.0-6
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.
- package/cjs-bundle/components/BICOffsetPickerDialog/components/Map/Map.js +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/components/Map/Map.js.map +1 -1
- package/cjs-bundle/components/OffsetWellMap/OffsetWellMap.js +1 -1
- package/cjs-bundle/components/OffsetWellMap/OffsetWellMap.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Map/Map.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Map/Map.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/OffsetWellMap.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/MapPreloader/MapPreloader.js +1 -1
- package/cjs-bundle/components/PinnableFilters/effects/index.js +1 -1
- package/cjs-bundle/components/PinnableFilters/effects/index.js.map +1 -1
- package/cjs-bundle/config/mapbox/index.js +1 -1
- package/cjs-bundle/config/mapbox/index.js.map +1 -1
- package/components/BICOffsetPickerDialog/components/Map/Map.d.ts.map +1 -1
- package/components/BICOffsetPickerDialog/components/Map/Map.js +1 -1
- package/components/BICOffsetPickerDialog/components/Map/Map.js.map +1 -1
- package/components/OffsetWellMap/OffsetWellMap.d.ts.map +1 -1
- package/components/OffsetWellMap/OffsetWellMap.js +1 -1
- package/components/OffsetWellMap/OffsetWellMap.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Map/Map.d.ts.map +1 -1
- package/components/OffsetWellPickerV2/components/Map/Map.js +1 -1
- package/components/OffsetWellPickerV2/components/Map/Map.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.d.ts.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js.map +1 -1
- package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/OffsetWellMap.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/OffsetWellMap.js +1 -1
- package/components/OffsetWellPickerV5/components/MapPreloader/MapPreloader.d.ts.map +1 -1
- package/components/OffsetWellPickerV5/components/MapPreloader/MapPreloader.js +1 -1
- package/components/PinnableFilters/effects/index.js +1 -1
- package/components/PinnableFilters/effects/index.js.map +1 -1
- package/config/mapbox/index.d.ts +1 -0
- package/config/mapbox/index.d.ts.map +1 -1
- package/config/mapbox/index.js +1 -1
- package/config/mapbox/index.js.map +1 -1
- package/mcp-server/server.mjs +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react"),t=require("react-dom"),u=require("prop-types"),a=require("lodash"),l=require("./Map.css.js"),n=require("../../../../utils/index.js");require("../../../../config/mapboxGl/index.js")
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react"),t=require("react-dom"),u=require("prop-types"),a=require("lodash"),l=require("./Map.css.js"),n=require("../../../../utils/index.js");require("../../../../config/mapboxGl/index.js");var o=require("../../../../config/mapbox/index.js");require("mapbox-gl/dist/mapbox-gl.css");var i=require("react/jsx-runtime"),s=require("mapbox-gl");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(e),f=c(t),p=c(u),m=c(s),g=n.mapbox.isValidCoordinates,v=[29.749907,-95.358421],y="wells-highlight",h={type:"FeatureCollection",features:[]},b=function(e){var r=d.default(e,2),t=r[0];return[r[1],t]};function w(e){var t=e.subjectWell,u=e.wells,n=e.offsetWells,s=e.radius,c=e.subjectWellMarkerSize,p=e.wellMarkerSize,w=e.coordsDataPath,x=r.useRef(null),j=r.useRef(null),S=r.useRef(null),M=r.useRef(null),q=r.useRef(),C=r.useState(!1),D=d.default(C,2),P=D[0],F=D[1],W=r.useMemo((function(){return t&&a.get(t,w)}),[t,w]);r.useEffect((function(){if(o.IS_MAPBOX_ENABLED){j.current=new m.default.Map({container:x.current,style:"mapbox://styles/mapbox/dark-v9",center:b(v),zoom:1,attributionControl:!1,scrollZoom:!1}),j.current.addControl(new m.default.NavigationControl({showCompass:!1}),"bottom-right"),j.current.on("load",(function(){j.current.addSource("radius-circle",{type:"geojson",data:h}),j.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),j.current.addSource("wells",{type:"geojson",data:h}),j.current.addLayer({id:"wells",type:"circle",source:"wells",paint:{"circle-radius":["get","radius"],"circle-color":"#FFC107","circle-opacity":["get","opacity"]}}),j.current.addSource(y,{type:"geojson",data:h}),j.current.addLayer({id:y,type:"circle",source:y,paint:{"circle-radius":["get","radius"],"circle-color":"#FFC107","circle-opacity":.2}}),F(!0)}));var e=j.current;return function(){e.remove(),j.current=null,S.current=null}}}),[]),r.useEffect((function(){if(j.current&&P)if(W){var e=function(e,r){for(var t=d.default(e,2),u=t[0],a=t[1],l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,n=[],o=r/(111320*Math.cos(u*Math.PI/180)),i=r/110574,s=0;s<=l;s+=1){var c=s/l*(2*Math.PI);n.push([a+o*Math.cos(c),u+i*Math.sin(c)])}return n}(W,1609.34*s);j.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[e]}})}else j.current.getSource("radius-circle").setData(h)}),[s,W,P]);return r.useEffect((function(){var e;if(j.current&&P){var l=q.current;q.current=u,null===(e=M.current)||void 0===e||e.remove(),j.current.getSource(y).setData(h);var o=n.map((function(e){return e.id})),s=[],d={},v=new m.default.LngLatBounds;u.forEach((function(e){var r=a.get(e,w);if(r&&g(r)){var u=t&&t.id===e.id,l=o.includes(e.id),n=u?c:p,i=u||l?1:.3;d[e.id]=e,v.extend(b(r)),s.push({type:"Feature",geometry:{type:"Point",coordinates:b(r)},properties:{wellId:e.id,radius:n,opacity:i}})}})),j.current.getSource("wells").setData({type:"FeatureCollection",features:s}),S.current=s.length?v:null;var x=j.current,C=null,D=function(e){x.getCanvas().style.cursor="pointer";var t=d[e.features[0].properties.wellId];if(t&&t.id!==C){C=t.id;var u=a.get(t,w),l=document.createElement("div"),n=r.createElement((function(e){var r=e.well;return i.jsx("div",{style:{color:"#fff",background:"##414141"},children:i.jsx("span",{style:{fontSize:"11px",lineHeight:"16px"},children:a.get(r,"name")})})}),{well:t});f.default.render(n,l),M.current||(M.current=new m.default.Popup({closeButton:!1,maxWidth:"none"})),M.current.setLngLat(b(u)).setDOMContent(l).addTo(x),function(e,r){j.current.getSource(y).setData({type:"Feature",geometry:{type:"Point",coordinates:b(e)},properties:{radius:3*r}})}(u,e.features[0].properties.radius)}},F=function(){var e;C=null,x.getCanvas().style.cursor="",x.getSource(y).setData(h),null===(e=M.current)||void 0===e||e.remove()},W=function(e){null!=e&&e.point&&x.queryRenderedFeatures(e.point,{layers:[y]}).length||F()};return x.on("mousemove","wells",D),x.on("mouseleave","wells",W),x.on("mouseleave",y,F),setTimeout((function(){j.current&&S.current&&u!==l&&j.current.fitBounds(S.current)}),500),function(){x.off("mousemove","wells",D),x.off("mouseleave","wells",W),x.off("mouseleave",y,F)}}}),[t,u,n,P]),i.jsx("div",{className:l.map,children:i.jsx("div",{className:l.mapMain,ref:x})})}w.propTypes={subjectWell:p.default.shape({id:p.default.number,formation:p.default.string}),wells:p.default.arrayOf(p.default.shape({})).isRequired,offsetWells:p.default.arrayOf(p.default.shape({})),radius:p.default.number.isRequired,subjectWellMarkerSize:p.default.number,wellMarkerSize:p.default.number,coordsDataPath:p.default.string},w.defaultProps={subjectWell:null,subjectWellMarkerSize:8,wellMarkerSize:5,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var x=r.memo(w);module.exports=x;
|
|
2
2
|
//# sourceMappingURL=Map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Map.js","sources":["../../../../../../src/components/BICOffsetPickerDialog/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get } from 'lodash';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport mapboxgl from '~/config/mapboxGl';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 8;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#FFC107';\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst HIGHLIGHT_ID = 'wells-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\nconst toolTip =\n () =>\n // eslint-disable-next-line react/prop-types\n ({ well }) => {\n return (\n <div style={{ color: '#fff', background: '##414141' }}>\n <span style={{ fontSize: '11px', lineHeight: '16px' }}>{get(well, 'name')}</span>\n </div>\n );\n };\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Initialize map\n useEffect(() => {\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack),\n // and the hover highlight layer last so it renders on top of the markers\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n mapRef.current.addSource(HIGHLIGHT_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: HIGHLIGHT_ID,\n type: 'circle',\n source: HIGHLIGHT_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': 0.2,\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n }, [radius, subjectWellCoords, isMapReady]);\n\n const handleMouseOver = (coords, r) => {\n // Highlight the hovered well with a bigger translucent circle\n mapRef.current.getSource(HIGHLIGHT_ID).setData({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { radius: r * 3 },\n });\n };\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n mapRef.current.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n const coords = get(well, coordsDataPath);\n\n // Tooltip\n const tooltipContainer = document.createElement('div');\n const tootipContent = createElement(toolTip(), { well });\n ReactDOM.render(tootipContent, tooltipContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current.setLngLat(toLngLat(coords)).setDOMContent(tooltipContainer).addTo(map);\n\n // Highlight\n handleMouseOver(coords, e.features[0].properties.radius);\n };\n\n // NOTE: was the mouseout handler of the Leaflet highlight marker\n const handleHighlightMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n map.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n popupRef.current?.remove();\n };\n\n // NOTE: If the pointer exits before the highlight renders under it, the highlight\n // layer never emits mouseleave — clear here unless the cursor is inside the highlight\n const handleWellsMouseLeave = e => {\n if (e?.point && map.queryRenderedFeatures(e.point, { layers: [HIGHLIGHT_ID] }).length) {\n return;\n }\n handleHighlightMouseLeave();\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.on('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && markersBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.off('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","HIGHLIGHT_ID","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref6","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","coordsDataPath","mapContainerRef","useRef","mapRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","subjectWellCoords","useMemo","get","useEffect","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","id","source","paint","map","remove","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","push","sin","makeCirclePolygon","getSource","setData","geometry","coordinates","_popupRef$current","prevWells","offsetWellIds","well","wellsById","bounds","LngLatBounds","forEach","coords","isWellSubject","isWellOffset","includes","r","opacity","extend","properties","wellId","length","hoveredWellId","handleMouseMove","e","getCanvas","cursor","tooltipContainer","document","createElement","tootipContent","_ref5","_jsx","color","background","children","jsx","fontSize","lineHeight","ReactDOM","render","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseOver","handleHighlightMouseLeave","_popupRef$current2","handleWellsMouseLeave","point","queryRenderedFeatures","layers","setTimeout","fitBounds","off","className","styles","mapMain","ref","propTypes","PropTypes","shape","number","formation","string","arrayOf","isRequired","defaultProps","memo"],"mappings":"qdAWQA,EAAuBC,EAAMA,OAA7BD,mBAQFE,EAAiB,CAAC,WAAY,WAI9BC,EAAe,kBACfC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAElEC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAA,QAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EA0B3C,SAASC,EAQNC,GAAA,IAPDC,IAAAA,YACAC,IAAAA,MACAC,IAAAA,YACAC,IAAAA,OACAC,IAAAA,sBACAC,IAAAA,eACAC,IAAAA,eAEMC,EAAkBC,SAAO,MACzBC,EAASD,SAAO,MAChBE,EAAmBF,SAAO,MAC1BG,EAAWH,SAAO,MAClBI,EAAeJ,EAAAA,SACeK,EAAAA,EAAQA,UAAC,GAAMC,EAAAlB,EAAAA,QAAAmB,EAAA,GAA5CC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAE1BI,EAAoBC,EAAAA,SAAQ,WAChC,OAAOnB,GAAeoB,EAAAA,IAAIpB,EAAaM,EACzC,GAAG,CAACN,EAAaM,IAGjBe,EAAAA,WAAU,WACRZ,EAAOa,QAAU,IAAIC,EAAQ,QAACC,IAAI,CAChCC,UAAWlB,EAAgBe,QAC3BI,MAAO,iCACPC,OAAQlC,EAASL,GACjBwC,KAAM,EACNC,oBAAoB,EACpBC,YAAY,IAGdrB,EAAOa,QAAQS,WACb,IAAIR,EAAAA,QAASS,kBAAkB,CAAEC,aAAa,IAC9C,gBAMFxB,EAAOa,QAAQY,GAAG,QAAQ,WACxBzB,EAAOa,QAAQa,UAvEI,gBAuEwB,CACzC5C,KAAM,UACN6C,KAAM9C,IAERmB,EAAOa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Dialog/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get } from 'lodash';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport mapboxgl from '~/config/mapboxGl';\nimport { IS_MAPBOX_ENABLED } from '~/config/mapbox';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 8;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#FFC107';\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst HIGHLIGHT_ID = 'wells-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\nconst toolTip =\n () =>\n // eslint-disable-next-line react/prop-types\n ({ well }) => {\n return (\n <div style={{ color: '#fff', background: '##414141' }}>\n <span style={{ fontSize: '11px', lineHeight: '16px' }}>{get(well, 'name')}</span>\n </div>\n );\n };\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Initialize map\n useEffect(() => {\n if (!IS_MAPBOX_ENABLED) return undefined;\n\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack),\n // and the hover highlight layer last so it renders on top of the markers\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n mapRef.current.addSource(HIGHLIGHT_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: HIGHLIGHT_ID,\n type: 'circle',\n source: HIGHLIGHT_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': OFFSET_WELL_COLOR,\n 'circle-opacity': 0.2,\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n }, [radius, subjectWellCoords, isMapReady]);\n\n const handleMouseOver = (coords, r) => {\n // Highlight the hovered well with a bigger translucent circle\n mapRef.current.getSource(HIGHLIGHT_ID).setData({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { radius: r * 3 },\n });\n };\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n mapRef.current.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n const coords = get(well, coordsDataPath);\n\n // Tooltip\n const tooltipContainer = document.createElement('div');\n const tootipContent = createElement(toolTip(), { well });\n ReactDOM.render(tootipContent, tooltipContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current.setLngLat(toLngLat(coords)).setDOMContent(tooltipContainer).addTo(map);\n\n // Highlight\n handleMouseOver(coords, e.features[0].properties.radius);\n };\n\n // NOTE: was the mouseout handler of the Leaflet highlight marker\n const handleHighlightMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n map.getSource(HIGHLIGHT_ID).setData(EMPTY_FEATURE_COLLECTION);\n popupRef.current?.remove();\n };\n\n // NOTE: If the pointer exits before the highlight renders under it, the highlight\n // layer never emits mouseleave — clear here unless the cursor is inside the highlight\n const handleWellsMouseLeave = e => {\n if (e?.point && map.queryRenderedFeatures(e.point, { layers: [HIGHLIGHT_ID] }).length) {\n return;\n }\n handleHighlightMouseLeave();\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.on('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && markersBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleWellsMouseLeave);\n map.off('mouseleave', HIGHLIGHT_ID, handleHighlightMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","HIGHLIGHT_ID","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref6","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","coordsDataPath","mapContainerRef","useRef","mapRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","subjectWellCoords","useMemo","get","useEffect","IS_MAPBOX_ENABLED","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","id","source","paint","map","remove","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","push","sin","makeCirclePolygon","getSource","setData","geometry","coordinates","_popupRef$current","prevWells","offsetWellIds","well","wellsById","bounds","LngLatBounds","forEach","coords","isWellSubject","isWellOffset","includes","r","opacity","extend","properties","wellId","length","hoveredWellId","handleMouseMove","e","getCanvas","cursor","tooltipContainer","document","createElement","tootipContent","_ref5","_jsx","color","background","children","jsx","fontSize","lineHeight","ReactDOM","render","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseOver","handleHighlightMouseLeave","_popupRef$current2","handleWellsMouseLeave","point","queryRenderedFeatures","layers","setTimeout","fitBounds","off","className","styles","mapMain","ref","propTypes","PropTypes","shape","number","formation","string","arrayOf","isRequired","defaultProps","memo"],"mappings":"ygBAYQA,EAAuBC,EAAMA,OAA7BD,mBAQFE,EAAiB,CAAC,WAAY,WAI9BC,EAAe,kBACfC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAElEC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAA,QAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EA0B3C,SAASC,EAQNC,GAAA,IAPDC,IAAAA,YACAC,IAAAA,MACAC,IAAAA,YACAC,IAAAA,OACAC,IAAAA,sBACAC,IAAAA,eACAC,IAAAA,eAEMC,EAAkBC,SAAO,MACzBC,EAASD,SAAO,MAChBE,EAAmBF,SAAO,MAC1BG,EAAWH,SAAO,MAClBI,EAAeJ,EAAAA,SACeK,EAAAA,EAAQA,UAAC,GAAMC,EAAAlB,EAAAA,QAAAmB,EAAA,GAA5CC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAE1BI,EAAoBC,EAAAA,SAAQ,WAChC,OAAOnB,GAAeoB,EAAAA,IAAIpB,EAAaM,EACzC,GAAG,CAACN,EAAaM,IAGjBe,EAAAA,WAAU,WACR,GAAKC,EAAAA,kBAAL,CAEAb,EAAOc,QAAU,IAAIC,EAAQ,QAACC,IAAI,CAChCC,UAAWnB,EAAgBgB,QAC3BI,MAAO,iCACPC,OAAQnC,EAASL,GACjByC,KAAM,EACNC,oBAAoB,EACpBC,YAAY,IAGdtB,EAAOc,QAAQS,WACb,IAAIR,EAAAA,QAASS,kBAAkB,CAAEC,aAAa,IAC9C,gBAMFzB,EAAOc,QAAQY,GAAG,QAAQ,WACxB1B,EAAOc,QAAQa,UAzEI,gBAyEwB,CACzC7C,KAAM,UACN8C,KAAM/C,IAERmB,EAAOc,QAAQe,SAA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ers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),l=require("react-dom"),i=require("lodash"),o=require("classnames"),c=require("@material-ui/core"),u=require("@material-ui/icons");require("mapbox-gl/dist/mapbox-gl.css");var n=require("./effects/usePreviousWells.js"),s=require("./WellTooltip.js"),a=require("./utils.js"),d=require("./OffsetWellMap.module.css.js");require("../../config/mapboxGl/index.js");var f=require("../../
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),l=require("react-dom"),i=require("lodash"),o=require("classnames"),c=require("@material-ui/core"),u=require("@material-ui/icons");require("mapbox-gl/dist/mapbox-gl.css");var n=require("./effects/usePreviousWells.js"),s=require("./WellTooltip.js"),a=require("./utils.js"),d=require("./OffsetWellMap.module.css.js");require("../../config/mapboxGl/index.js");var f=require("../../config/mapbox/index.js"),v=require("../../utils/index.js"),h=require("react/jsx-runtime"),m=require("mapbox-gl");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=g(e),y=g(r),w=g(l),b=g(o),j=g(m),x=v.mapbox.isValidCoordinates,W=[29.749907,-95.358421],q={type:"FeatureCollection",features:[]},F=["==",["id"],-1],B=function(e){var r=y.default(e,2),t=r[0];return[r[1],t]},C=function(e,r){for(var t=y.default(e,2),l=t[0],i=t[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,c=r/(111320*Math.cos(l*Math.PI/180)),u=r/110574,n=[],s=0;s<=o;s+=1){var a=s/o*2*Math.PI;n.push([i+c*Math.cos(a),l+u*Math.sin(a)])}return{type:"Polygon",coordinates:[n]}};module.exports=function(e){var r=e.isViewOnly,l=e.subjectWell,o=void 0===l?null:l,v=e.wells,m=e.offsetWellIds,g=e.radius,E=e.handleChanageOffsetWell,M=e.handleChangeOffsetWell,L=void 0===M?E:M,S=e.activeWellId,D=e.isClickable,O=void 0===D||D,P=e.classes,k=void 0===P?{}:P,R=t.useMemo((function(){return o&&i.get(o,"topHole.coordinates")}),[o]),I=t.useMemo((function(){return a.getAllFormations(v)}),[v]),T=t.useRef(),z=t.useRef(),Z=t.useRef(),N=t.useRef(null),A=t.useRef(null),V=t.useRef(),G=t.useRef(new Map),H=t.useRef(null),_=t.useRef(null),X=t.useState(!1),J=y.default(X,2),K=J[0],Q=J[1],U=(null==o?void 0:o.id)===S,Y=n.usePreviousWells(v),$=t.useState(!1),ee=y.default($,2),re=ee[0],te=ee[1],le=t.useState(3),ie=y.default(le,2),oe=ie[0],ce=ie[1];t.useEffect((function(){if(f.IS_MAPBOX_ENABLED){var e=new j.default.Map({container:T.current,style:"mapbox://styles/mapbox/dark-v9",center:B(W),zoom:3,maxZoom:18,attributionControl:!1,scrollZoom:!1,doubleClickZoom:!1});return z.current=e,e.on("zoomend",(function(){return ce(Math.round(e.getZoom()))})),e.on("load",(function(){e.addSource("radius-circle",{type:"geojson",data:q}),e.addLayer({id:"radius-circle-fill",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),e.addSource("wells",{type:"geojson",data:q}),e.addLayer({id:"wells-halo",type:"circle",source:"wells",filter:["==",["get","isOffsetWell"],!0],paint:{"circle-radius":12,"circle-color":["get","color"],"circle-opacity":.08}}),e.addLayer({id:"wells-circle",type:"circle",source:"wells",layout:{"circle-sort-key":["get","order"]},paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),e.addLayer({id:"wells-active-highlight",type:"circle",source:"wells",filter:["==",["get","isActive"],!0],paint:{"circle-radius":12,"circle-color":["get","color"],"circle-opacity":.24}}),e.addLayer({id:"wells-hover-highlight",type:"circle",source:"wells",filter:F,paint:{"circle-radius":["case",["get","isSubjectWell"],5,12],"circle-color":["case",["get","isSubjectWell"],"#63EFFF",["get","color"]],"circle-opacity":.24}}),te(!0)})),function(){e.remove(),z.current=null,Z.current=null,V.current=null,N.current=null,A.current=null}}}),[]),t.useEffect((function(){var e,r,t,l,i,o,c;N.current=R&&g?(e=R,r=1609.34*g,t=y.default(e,2),l=t[0],i=t[1],o=r/(111320*Math.cos(l*Math.PI/180)),[[i-o,l-(c=r/110574)],[i+o,l+c]]):null;var u=z.current;u&&re&&u.getSource("radius-circle").setData(R&&g?{type:"Feature",properties:{},geometry:C(R,1609.34*g)}:q)}),[g,R,re]);var ue=function(e,l,o,c){var u=document.createElement("div"),n=t.createElement(s.WellTooltip(),{isViewOnly:r,well:e,color:i.get(I,e.formation,"#BDBDBD"),isOffsetWell:l,isSubjectWell:o,isClickable:O});w.default.render(h.jsx(h.Fragment,{children:n}),u),Z.current||(Z.current=new j.default.Popup({closeButton:!1,offset:12})),Z.current.setLngLat(B(c)).setDOMContent(u).addTo(z.current)};t.useEffect((function(){var e=z.current;e&&re&&e.setPaintProperty("wells-circle","circle-color",K?["case",["get","isSubjectWell"],"#63EFFF",["get","color"]]:["get","color"])}),[K,re]),t.useEffect((function(){var e;if(v&&m){null===(e=Z.current)||void 0===e||e.remove();var t=[],l=[];v.forEach((function(e){e.id!==(null==o?void 0:o.id)&&(m.includes(e.id)?t.push(e):l.push(e))}));var c=[].concat(l,t,[o]),u=[],n=new j.default.LngLatBounds;G.current.clear(),H.current=null,c.forEach((function(e,r){var t,l=null==e||null===(t=e.topHole)||void 0===t?void 0:t.coordinates;if(l&&x(l)){var c=(null==o?void 0:o.id)===e.id,s=m.includes(e.id)&&!c,a=c?"#03BCD4":i.get(I,e.formation,"#BDBDBD"),d=s?.7:.3;u.push({type:"Feature",id:r,geometry:{type:"Point",coordinates:B(l)},properties:{color:a,opacity:c?1:d,isSubjectWell:c,isOffsetWell:s,isActive:e.id===S&&!U,order:r}}),G.current.set(r,{well:e,coords:l,isOffsetWell:s,isSubjectWell:c}),c&&(H.current=r),n.extend(B(l))}})),A.current=u.length?n:null;var s=z.current;if(s&&re){s.getSource("wells").setData({type:"FeatureCollection",features:u}),s.setFilter("wells-hover-highlight",F),_.current=null;var a=function(e){var r,t=null===(r=e.features)||void 0===r?void 0:r[0];if(t&&_.current!==t.id){var l=G.current.get(t.id);l&&(_.current=t.id,s.getCanvas().style.cursor="pointer",s.setFilter("wells-hover-highlight",["==",["id"],t.id]),ue(l.well,l.isOffsetWell,l.isSubjectWell,l.coords),l.isSubjectWell&&Q(!0))}},d=function(e){var r;if(null==e||!e.point||!s.queryRenderedFeatures(e.point,{layers:["wells-circle","wells-hover-highlight"]}).length){var t=null!==_.current&&_.current===H.current;_.current=null,s.getCanvas().style.cursor="",s.setFilter("wells-hover-highlight",F),null===(r=Z.current)||void 0===r||r.remove(),t&&Q(!1)}},f=function(e){var t,l;if(!r){var i=G.current.get(null===(t=e.features)||void 0===t||null===(l=t[0])||void 0===l?void 0:l.id);i&&L(i.well,!i.isOffsetWell)}};return s.on("mousemove","wells-circle",a),s.on("mouseleave","wells-circle",d),s.on("mouseleave","wells-hover-highlight",d),s.on("click","wells-circle",f),setTimeout((function(){g<3e3&&z.current&&N.current&&v!==Y&&z.current.fitBounds(N.current,{padding:5})}),500),function(){s.off("mousemove","wells-circle",a),s.off("mouseleave","wells-circle",d),s.off("mouseleave","wells-hover-highlight",d),s.off("click","wells-circle",f)}}}}),[o,v,m,S,re]),t.useEffect((function(){var e=z.current;if(V.current&&(V.current.remove(),V.current=null),e&&R){var r=K||U,t=document.createElement("img");t.src=r?"/static/media/5e9c4959259cb12c11b2c5eaf27eb3ad.svg":"/static/media/9efe5882f31d2f22bd57af92069d0a3e.svg";var l=r?[70,20]:[62,12],i=y.default(l,2),c=i[0],u=i[1],n=r?[35,29]:[31,25],s=y.default(n,2),a=s[0],d=s[1];t.width=c,t.height=u,t.addEventListener("mouseover",(function(){Q(!0),null!==H.current&&e.getLayer("wells-hover-highlight")&&(_.current=H.current,e.setFilter("wells-hover-highlight",["==",["id"],H.current])),ue(o,!1,!0,R)})),t.addEventListener("mouseout",(function(){var r;_.current=null,e.getLayer("wells-hover-highlight")&&e.setFilter("wells-hover-highlight",F),null===(r=Z.current)||void 0===r||r.remove(),Q(!1)})),V.current=new j.default.Marker({element:t,anchor:"center",offset:[c/2-a,u/2-d]}).setLngLat(B(R)).addTo(e)}}),[K,R,g,o,U]),t.useEffect((function(){var e;g>3e3?null===(e=z.current)||void 0===e||e.setZoom(1):setTimeout((function(){o?z.current&&N.current&&g&&z.current.fitBounds(N.current,{padding:5}):z.current&&A.current&&z.current.fitBounds(A.current),R&&z.current&&z.current.easeTo({center:B(R),duration:700})}),500)}),[g,o,R]);var ne=function(){var e;null===(e=z.current)||void 0===e||e.setZoom(oe+1)};return h.jsx("div",{className:b.default(d.mapView,k.root),children:h.jsx("div",{className:b.default(d.mapMain,k.map),ref:T,onDoubleClick:ne,children:h.jsxs("div",{className:d.zoomGroup,children:[h.jsx(c.Tooltip,{title:oe<18?"Zoom in":"",placement:"left",children:h.jsx("div",{className:b.default(d.zoomButton,p.default({},d.zoomDisabled,18===oe)),onClick:ne,children:h.jsx(u.Add,{className:d.zoomInOutIcon})})}),h.jsx(c.Tooltip,{title:oe>1?"Zoom out":"",placement:"left",children:h.jsx("div",{className:b.default(d.zoomButton,p.default({},d.zoomDisabled,1===oe)),onClick:function(){var e;oe>1&&(null===(e=z.current)||void 0===e||e.setZoom(oe-1))},children:h.jsx(u.Remove,{className:d.zoomInOutIcon})})})]})})})};
|
|
2
2
|
//# sourceMappingURL=OffsetWellMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OffsetWellMap.js","sources":["../../../../src/components/OffsetWellMap/OffsetWellMap.js"],"sourcesContent":["import { createElement, useRef, useEffect, useState, useMemo } from 'react';\nimport ReactDOM from 'react-dom';\nimport { get } from 'lodash';\nimport classNames from 'classnames';\nimport { Tooltip } from '@material-ui/core';\nimport { Add as ZoomInIcon, Remove as ZoomOutIcon } from '@material-ui/icons';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nimport SubjectWellIcon from './CustomIcon/SubjectWellIcon.svg';\nimport SubjectHighlightWellIcon from './CustomIcon/SubjectHighlightWellIcon.svg';\nimport { usePreviousWells } from './effects';\nimport { WellTooltip } from './WellTooltip';\nimport { getAllFormations } from './utils';\n\nimport styles from './OffsetWellMap.module.css';\n\nimport mapboxgl from '~/config/mapboxGl';\nimport { mapbox } from '~/utils';\n\nconst { isValidCoordinates } = mapbox;\nconst DEFAULT_COORDS = [29.749907, -95.358421];\nconst WELL_MARKER_SIZE = 5;\nconst HIGHLIGHT_MARKER_SIZE = 12;\nconst OFFSET_WELL_COLOR = '#03BCD4';\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst HIGHLIGHT_WELL_COLOR = '#63EFFF';\nconst METERS_IN_MILE = 1609.34;\nconst ZOOM_INIT_VALUE = 3;\nconst ZOOM_MAX_VALUE = 18;\nconst ZOOM_MIN_VALUE = 1;\nconst MAX_RADIUS = 3000;\n\nconst RADIUS_SOURCE_ID = 'radius-circle';\nconst RADIUS_LAYER_ID = 'radius-circle-fill';\nconst WELLS_SOURCE_ID = 'wells';\nconst WELLS_HALO_LAYER_ID = 'wells-halo';\nconst WELLS_LAYER_ID = 'wells-circle';\nconst WELLS_ACTIVE_LAYER_ID = 'wells-active-highlight';\nconst WELLS_HOVER_LAYER_ID = 'wells-hover-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\nconst NO_HOVER_FILTER = ['==', ['id'], -1];\n\n// NOTE: Props keep the Leaflet [lat, lng] convention; mapbox-gl expects [lng, lat]\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl circle layers are pixel-radius, so approximate the meter radius with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n const ring = [];\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * 2 * Math.PI;\n ring.push([lng + degreesLng * Math.cos(theta), lat + degreesLat * Math.sin(theta)]);\n }\n return { type: 'Polygon', coordinates: [ring] };\n};\n\nconst getCircleBounds = ([lat, lng], radiusMeters) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n return [\n [lng - degreesLng, lat - degreesLat],\n [lng + degreesLng, lat + degreesLat],\n ];\n};\n\n/** @type {React.FC<import('./OffsetWellMapProps').OffsetWellMapProps>} */\nconst OffsetWellMap = ({\n isViewOnly,\n subjectWell = null,\n wells,\n offsetWellIds,\n radius,\n handleChanageOffsetWell,\n handleChangeOffsetWell = handleChanageOffsetWell,\n activeWellId,\n isClickable = true,\n classes = {},\n}) => {\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, 'topHole.coordinates');\n }, [subjectWell]);\n const formationColors = useMemo(() => getAllFormations(wells), [wells]);\n\n const containerRef = useRef();\n const mapRef = useRef();\n const popupRef = useRef();\n const radiusBoundsRef = useRef(null);\n const wellsBoundsRef = useRef(null);\n const subjectIconRef = useRef();\n const wellByFeatureIdRef = useRef(new Map());\n const subjectFeatureIdRef = useRef(null);\n const hoveredFeatureIdRef = useRef(null);\n const [isSubjectWellHovered, setIsSubjectWellHovered] = useState(false);\n const isActiveWellIsSubjectWell = subjectWell?.id === activeWellId;\n const prevWells = usePreviousWells(wells);\n const [isMapReady, setIsMapReady] = useState(false);\n const [zoom, setZoom] = useState(ZOOM_INIT_VALUE);\n\n // NOTE: Initialize map\n useEffect(() => {\n const map = new mapboxgl.Map({\n container: containerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: ZOOM_INIT_VALUE,\n // NOTE: keep the zoom buttons' disable logic (zoom === ZOOM_MAX_VALUE) reachable\n maxZoom: ZOOM_MAX_VALUE,\n attributionControl: false,\n scrollZoom: false,\n doubleClickZoom: false,\n });\n mapRef.current = map;\n\n // NOTE: GL zoom is fractional where Leaflet was integer\n map.on('zoomend', () => setZoom(Math.round(map.getZoom())));\n\n // NOTE: Sources/layers can only be added after the style loads\n map.on('load', () => {\n map.addSource(RADIUS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: RADIUS_LAYER_ID,\n type: 'fill',\n source: RADIUS_SOURCE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n map.addSource(WELLS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: WELLS_HALO_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isOffsetWell'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.08,\n },\n });\n map.addLayer({\n id: WELLS_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n layout: {\n 'circle-sort-key': ['get', 'order'],\n },\n paint: {\n 'circle-radius': WELL_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n map.addLayer({\n id: WELLS_ACTIVE_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isActive'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.24,\n },\n });\n map.addLayer({\n id: WELLS_HOVER_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: NO_HOVER_FILTER,\n paint: {\n 'circle-radius': [\n 'case',\n ['get', 'isSubjectWell'],\n WELL_MARKER_SIZE,\n HIGHLIGHT_MARKER_SIZE,\n ],\n 'circle-color': [\n 'case',\n ['get', 'isSubjectWell'],\n HIGHLIGHT_WELL_COLOR,\n ['get', 'color'],\n ],\n 'circle-opacity': 0.24,\n },\n });\n\n setIsMapReady(true);\n });\n\n return () => {\n map.remove();\n mapRef.current = null;\n popupRef.current = null;\n subjectIconRef.current = null;\n radiusBoundsRef.current = null;\n wellsBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n radiusBoundsRef.current =\n subjectWellCoords && radius\n ? getCircleBounds(subjectWellCoords, radius * METERS_IN_MILE)\n : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.getSource(RADIUS_SOURCE_ID).setData(\n subjectWellCoords && radius\n ? {\n type: 'Feature',\n properties: {},\n geometry: makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE),\n }\n : EMPTY_FEATURE_COLLECTION\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n const showTooltip = (well, isOffsetWell, isSubjectWell, coords) => {\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(WellTooltip(), {\n isViewOnly,\n well,\n color: get(formationColors, well.formation, '#BDBDBD'),\n isOffsetWell,\n isSubjectWell,\n isClickable,\n });\n ReactDOM.render(<>{popUpContent}</>, popUpContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({\n closeButton: false,\n offset: HIGHLIGHT_MARKER_SIZE,\n });\n }\n popupRef.current\n .setLngLat(toLngLat(coords))\n .setDOMContent(popUpContainer)\n .addTo(mapRef.current);\n };\n\n // NOTE: Subject well hover swaps the subject marker color\n useEffect(() => {\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.setPaintProperty(\n WELLS_LAYER_ID,\n 'circle-color',\n isSubjectWellHovered\n ? ['case', ['get', 'isSubjectWell'], HIGHLIGHT_WELL_COLOR, ['get', 'color']]\n : ['get', 'color']\n );\n }, [isSubjectWellHovered, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!wells || !offsetWellIds) {\n return undefined;\n }\n\n popupRef.current?.remove();\n\n const offsetWells = [];\n const unSelectedWells = [];\n wells.forEach(well => {\n if (well.id !== subjectWell?.id) {\n if (offsetWellIds.includes(well.id)) {\n offsetWells.push(well);\n } else {\n unSelectedWells.push(well);\n }\n }\n });\n const sortedWells = [...unSelectedWells, ...offsetWells, subjectWell];\n\n const features = [];\n const wellsBounds = new mapboxgl.LngLatBounds();\n wellByFeatureIdRef.current.clear();\n subjectFeatureIdRef.current = null;\n sortedWells.forEach((well, index) => {\n const coords = well?.topHole?.coordinates;\n\n if (coords && isValidCoordinates(coords)) {\n const isSubjectWell = subjectWell?.id === well.id;\n const isOffsetWell = offsetWellIds.includes(well.id) && !isSubjectWell;\n const color = isSubjectWell\n ? OFFSET_WELL_COLOR\n : get(formationColors, well.formation, '#BDBDBD');\n const opacity = isOffsetWell ? 0.7 : 0.3;\n\n features.push({\n type: 'Feature',\n id: index,\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: {\n color,\n opacity: isSubjectWell ? 1 : opacity,\n isSubjectWell,\n isOffsetWell,\n isActive: well.id === activeWellId && !isActiveWellIsSubjectWell,\n order: index,\n },\n });\n wellByFeatureIdRef.current.set(index, { well, coords, isOffsetWell, isSubjectWell });\n if (isSubjectWell) {\n subjectFeatureIdRef.current = index;\n }\n wellsBounds.extend(toLngLat(coords));\n }\n });\n wellsBoundsRef.current = features.length ? wellsBounds : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return undefined;\n }\n\n map.getSource(WELLS_SOURCE_ID).setData({ type: 'FeatureCollection', features });\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n hoveredFeatureIdRef.current = null;\n\n const handleMouseMove = e => {\n const feature = e.features?.[0];\n if (!feature || hoveredFeatureIdRef.current === feature.id) {\n return;\n }\n const entry = wellByFeatureIdRef.current.get(feature.id);\n if (!entry) {\n return;\n }\n\n hoveredFeatureIdRef.current = feature.id;\n map.getCanvas().style.cursor = 'pointer';\n\n // Highlight\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], feature.id]);\n showTooltip(entry.well, entry.isOffsetWell, entry.isSubjectWell, entry.coords);\n if (entry.isSubjectWell) {\n setIsSubjectWellHovered(true);\n }\n };\n\n const handleMouseLeave = e => {\n // NOTE: Leaflet cleared hover on leaving the ENLARGED highlight marker, so keep the\n // hover while the cursor is still over the hover halo (or another well marker)\n if (\n e?.point &&\n map.queryRenderedFeatures(e.point, { layers: [WELLS_LAYER_ID, WELLS_HOVER_LAYER_ID] })\n .length\n ) {\n return;\n }\n const wasSubjectWell =\n hoveredFeatureIdRef.current !== null &&\n hoveredFeatureIdRef.current === subjectFeatureIdRef.current;\n hoveredFeatureIdRef.current = null;\n map.getCanvas().style.cursor = '';\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n popupRef.current?.remove();\n if (wasSubjectWell) {\n setIsSubjectWellHovered(false);\n }\n };\n\n const handleClick = e => {\n if (isViewOnly) return;\n const entry = wellByFeatureIdRef.current.get(e.features?.[0]?.id);\n if (!entry) {\n return;\n }\n handleChangeOffsetWell(entry.well, !entry.isOffsetWell);\n };\n\n map.on('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.on('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.on('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.on('click', WELLS_LAYER_ID, handleClick);\n\n setTimeout(() => {\n if (radius < MAX_RADIUS && mapRef.current && radiusBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.off('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.off('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.off('click', WELLS_LAYER_ID, handleClick);\n };\n }, [subjectWell, wells, offsetWellIds, activeWellId, isMapReady]);\n\n // NOTE: Subject Well Icon\n\n useEffect(() => {\n const map = mapRef.current;\n\n if (subjectIconRef.current) {\n subjectIconRef.current.remove();\n subjectIconRef.current = null;\n }\n\n if (!map || !subjectWellCoords) return;\n\n const isHighlighted = isSubjectWellHovered || isActiveWellIsSubjectWell;\n const icon = document.createElement('img');\n icon.src = isHighlighted ? SubjectHighlightWellIcon : SubjectWellIcon;\n const [iconWidth, iconHeight] = isHighlighted ? [70, 20] : [62, 12];\n const [anchorX, anchorY] = isHighlighted ? [35, 29] : [31, 25];\n icon.width = iconWidth;\n icon.height = iconHeight;\n\n icon.addEventListener('mouseover', () => {\n setIsSubjectWellHovered(true);\n\n // Highlight\n if (subjectFeatureIdRef.current !== null && map.getLayer(WELLS_HOVER_LAYER_ID)) {\n hoveredFeatureIdRef.current = subjectFeatureIdRef.current;\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], subjectFeatureIdRef.current]);\n }\n showTooltip(subjectWell, false, true, subjectWellCoords);\n });\n\n icon.addEventListener('mouseout', () => {\n hoveredFeatureIdRef.current = null;\n if (map.getLayer(WELLS_HOVER_LAYER_ID)) {\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n }\n popupRef.current?.remove();\n setIsSubjectWellHovered(false);\n });\n\n subjectIconRef.current = new mapboxgl.Marker({\n element: icon,\n anchor: 'center',\n // NOTE: Leaflet anchored the icon at [anchorX, anchorY] from its top-left corner\n offset: [iconWidth / 2 - anchorX, iconHeight / 2 - anchorY],\n })\n .setLngLat(toLngLat(subjectWellCoords))\n .addTo(map);\n }, [isSubjectWellHovered, subjectWellCoords, radius, subjectWell, isActiveWellIsSubjectWell]);\n\n // NOTE: Map Update\n useEffect(() => {\n if (radius > MAX_RADIUS) {\n mapRef.current.setZoom(1);\n return;\n }\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusBoundsRef.current && radius) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n } else if (mapRef.current && wellsBoundsRef.current) {\n mapRef.current.fitBounds(wellsBoundsRef.current);\n }\n if (subjectWellCoords && mapRef.current) {\n mapRef.current.easeTo({ center: toLngLat(subjectWellCoords), duration: 700 });\n }\n }, 500);\n }, [radius, subjectWell, subjectWellCoords]);\n\n const handleZoomIn = () => {\n mapRef.current.setZoom(zoom + 1);\n };\n\n const handleZoomOut = () => {\n if (zoom > 1) {\n mapRef.current.setZoom(zoom - 1);\n }\n };\n\n return (\n <div className={classNames(styles.mapView, classes.root)}>\n <div\n className={classNames(styles.mapMain, classes.map)}\n ref={containerRef}\n onDoubleClick={handleZoomIn}\n >\n <div className={styles.zoomGroup}>\n <Tooltip title={zoom < ZOOM_MAX_VALUE ? 'Zoom in' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MAX_VALUE,\n })}\n onClick={handleZoomIn}\n >\n <ZoomInIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n <Tooltip title={zoom > ZOOM_MIN_VALUE ? 'Zoom out' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MIN_VALUE,\n })}\n onClick={handleZoomOut}\n >\n <ZoomOutIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n </div>\n </div>\n </div>\n );\n};\n\nexport default OffsetWellMap;\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","NO_HOVER_FILTER","toLngLat","_ref","_ref2","_slicedToArray","lat","makeCirclePolygon","_ref3","radiusMeters","_ref4","lng","points","degreesLng","Math","cos","PI","degreesLat","ring","i","theta","push","sin","coordinates","_ref7","isViewOnly","_ref7$subjectWell","subjectWell","wells","offsetWellIds","radius","handleChanageOffsetWell","_ref7$handleChangeOff","handleChangeOffsetWell","activeWellId","_ref7$isClickable","isClickable","_ref7$classes","classes","subjectWellCoords","useMemo","get","formationColors","getAllFormations","containerRef","useRef","mapRef","popupRef","radiusBoundsRef","wellsBoundsRef","subjectIconRef","wellByFeatureIdRef","Map","subjectFeatureIdRef","hoveredFeatureIdRef","useState","_useState2","_useState","isSubjectWellHovered","setIsSubjectWellHovered","isActiveWellIsSubjectWell","id","prevWells","usePreviousWells","_useState4","_useState3","isMapReady","setIsMapReady","_useState6","_useState5","zoom","setZoom","useEffect","map","mapboxgl","container","current","style","center","maxZoom","attributionControl","scrollZoom","doubleClickZoom","on","round","getZoom","addSource","data","addLayer","source","paint","filter","layout","remove","_ref5","_ref6","getSource","setData","properties","geometry","showTooltip","well","isOffsetWell","isSubjectWell","coords","popUpContainer","document","createElement","popUpContent","WellTooltip","color","formation","ReactDOM","render","_jsx","jsx","_Fragment","children","Popup","closeButton","offset","setLngLat","setDOMContent","addTo","setPaintProperty","_popupRef$current","offsetWells","unSelectedWells","forEach","includes","sortedWells","wellsBounds","LngLatBounds","clear","index","_well$topHole","topHole","opacity","isActive","order","set","extend","length","setFilter","handleMouseMove","e","_e$features","feature","entry","getCanvas","cursor","handleMouseLeave","_popupRef$current2","point","queryRenderedFeatures","layers","wasSubjectWell","handleClick","_e$features2","_e$features2$","setTimeout","fitBounds","padding","off","isHighlighted","icon","src","_ref8","_ref9","iconWidth","iconHeight","_ref10","_ref11","anchorX","anchorY","width","height","addEventListener","getLayer","_popupRef$current3","Marker","element","anchor","easeTo","duration","handleZoomIn","className","classNames","styles","mapView","root","mapMain","ref","onDoubleClick","_jsxs","jsxs","zoomGroup","Tooltip","title","placement","zoomButton","_defineProperty","zoomDisabled","onClick","ZoomInIcon","zoomInOutIcon","ZoomOutIcon"],"mappings":"wrBAmBQA,EAAuBC,EAAMA,OAA7BD,mBACFE,EAAiB,CAAC,WAAY,WAmB9BC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAClEC,EAAkB,CAAC,KAAM,CAAC,OAAQ,GAGlCC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAA,QAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EAGrCC,EAAoB,SAAHC,EAAgBC,GAIrC,IAJmE,IAAAC,EAAAL,EAAAA,QAAAG,EAAA,GAAzCF,EAAGI,EAAA,GAAEC,EAAGD,EAAA,GAAiBE,yDAAS,GACtDC,EAAaJ,GAAgB,OAASK,KA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IiI,UAAU,OAAMlF,SACvEH,EAAAC,IAAA,MAAA,CACEuE,UAAWC,EAAU,QAACC,EAAOY,WAAUC,EAAA,QAAA,GACpCb,EAAOc,aAzdD,IAydgBpI,KAEzBqI,QA7BU,WAChBrI,GAAO,GACTxB,EAAO8B,QAAQL,QAAQD,GAAO,IA2BC+C,SAEvBH,MAAC4F,SAAW,CAACpB,UAAWE,EAAOiB,0BAO7C"}
|
|
1
|
+
{"version":3,"file":"OffsetWellMap.js","sources":["../../../../src/components/OffsetWellMap/OffsetWellMap.js"],"sourcesContent":["import { createElement, useRef, useEffect, useState, useMemo } from 'react';\nimport ReactDOM from 'react-dom';\nimport { get } from 'lodash';\nimport classNames from 'classnames';\nimport { Tooltip } from '@material-ui/core';\nimport { Add as ZoomInIcon, Remove as ZoomOutIcon } from '@material-ui/icons';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nimport SubjectWellIcon from './CustomIcon/SubjectWellIcon.svg';\nimport SubjectHighlightWellIcon from './CustomIcon/SubjectHighlightWellIcon.svg';\nimport { usePreviousWells } from './effects';\nimport { WellTooltip } from './WellTooltip';\nimport { getAllFormations } from './utils';\n\nimport styles from './OffsetWellMap.module.css';\n\nimport mapboxgl from '~/config/mapboxGl';\nimport { IS_MAPBOX_ENABLED } from '~/config/mapbox';\nimport { mapbox } from '~/utils';\n\nconst { isValidCoordinates } = mapbox;\nconst DEFAULT_COORDS = [29.749907, -95.358421];\nconst WELL_MARKER_SIZE = 5;\nconst HIGHLIGHT_MARKER_SIZE = 12;\nconst OFFSET_WELL_COLOR = '#03BCD4';\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst HIGHLIGHT_WELL_COLOR = '#63EFFF';\nconst METERS_IN_MILE = 1609.34;\nconst ZOOM_INIT_VALUE = 3;\nconst ZOOM_MAX_VALUE = 18;\nconst ZOOM_MIN_VALUE = 1;\nconst MAX_RADIUS = 3000;\n\nconst RADIUS_SOURCE_ID = 'radius-circle';\nconst RADIUS_LAYER_ID = 'radius-circle-fill';\nconst WELLS_SOURCE_ID = 'wells';\nconst WELLS_HALO_LAYER_ID = 'wells-halo';\nconst WELLS_LAYER_ID = 'wells-circle';\nconst WELLS_ACTIVE_LAYER_ID = 'wells-active-highlight';\nconst WELLS_HOVER_LAYER_ID = 'wells-hover-highlight';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\nconst NO_HOVER_FILTER = ['==', ['id'], -1];\n\n// NOTE: Props keep the Leaflet [lat, lng] convention; mapbox-gl expects [lng, lat]\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl circle layers are pixel-radius, so approximate the meter radius with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n const ring = [];\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * 2 * Math.PI;\n ring.push([lng + degreesLng * Math.cos(theta), lat + degreesLat * Math.sin(theta)]);\n }\n return { type: 'Polygon', coordinates: [ring] };\n};\n\nconst getCircleBounds = ([lat, lng], radiusMeters) => {\n const degreesLng = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const degreesLat = radiusMeters / 110574;\n return [\n [lng - degreesLng, lat - degreesLat],\n [lng + degreesLng, lat + degreesLat],\n ];\n};\n\n/** @type {React.FC<import('./OffsetWellMapProps').OffsetWellMapProps>} */\nconst OffsetWellMap = ({\n isViewOnly,\n subjectWell = null,\n wells,\n offsetWellIds,\n radius,\n handleChanageOffsetWell,\n handleChangeOffsetWell = handleChanageOffsetWell,\n activeWellId,\n isClickable = true,\n classes = {},\n}) => {\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, 'topHole.coordinates');\n }, [subjectWell]);\n const formationColors = useMemo(() => getAllFormations(wells), [wells]);\n\n const containerRef = useRef();\n const mapRef = useRef();\n const popupRef = useRef();\n const radiusBoundsRef = useRef(null);\n const wellsBoundsRef = useRef(null);\n const subjectIconRef = useRef();\n const wellByFeatureIdRef = useRef(new Map());\n const subjectFeatureIdRef = useRef(null);\n const hoveredFeatureIdRef = useRef(null);\n const [isSubjectWellHovered, setIsSubjectWellHovered] = useState(false);\n const isActiveWellIsSubjectWell = subjectWell?.id === activeWellId;\n const prevWells = usePreviousWells(wells);\n const [isMapReady, setIsMapReady] = useState(false);\n const [zoom, setZoom] = useState(ZOOM_INIT_VALUE);\n\n // NOTE: Initialize map\n useEffect(() => {\n if (!IS_MAPBOX_ENABLED) return undefined;\n\n const map = new mapboxgl.Map({\n container: containerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: ZOOM_INIT_VALUE,\n // NOTE: keep the zoom buttons' disable logic (zoom === ZOOM_MAX_VALUE) reachable\n maxZoom: ZOOM_MAX_VALUE,\n attributionControl: false,\n scrollZoom: false,\n doubleClickZoom: false,\n });\n mapRef.current = map;\n\n // NOTE: GL zoom is fractional where Leaflet was integer\n map.on('zoomend', () => setZoom(Math.round(map.getZoom())));\n\n // NOTE: Sources/layers can only be added after the style loads\n map.on('load', () => {\n map.addSource(RADIUS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: RADIUS_LAYER_ID,\n type: 'fill',\n source: RADIUS_SOURCE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n map.addSource(WELLS_SOURCE_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n map.addLayer({\n id: WELLS_HALO_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isOffsetWell'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.08,\n },\n });\n map.addLayer({\n id: WELLS_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n layout: {\n 'circle-sort-key': ['get', 'order'],\n },\n paint: {\n 'circle-radius': WELL_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n map.addLayer({\n id: WELLS_ACTIVE_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: ['==', ['get', 'isActive'], true],\n paint: {\n 'circle-radius': HIGHLIGHT_MARKER_SIZE,\n 'circle-color': ['get', 'color'],\n 'circle-opacity': 0.24,\n },\n });\n map.addLayer({\n id: WELLS_HOVER_LAYER_ID,\n type: 'circle',\n source: WELLS_SOURCE_ID,\n filter: NO_HOVER_FILTER,\n paint: {\n 'circle-radius': [\n 'case',\n ['get', 'isSubjectWell'],\n WELL_MARKER_SIZE,\n HIGHLIGHT_MARKER_SIZE,\n ],\n 'circle-color': [\n 'case',\n ['get', 'isSubjectWell'],\n HIGHLIGHT_WELL_COLOR,\n ['get', 'color'],\n ],\n 'circle-opacity': 0.24,\n },\n });\n\n setIsMapReady(true);\n });\n\n return () => {\n map.remove();\n mapRef.current = null;\n popupRef.current = null;\n subjectIconRef.current = null;\n radiusBoundsRef.current = null;\n wellsBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n radiusBoundsRef.current =\n subjectWellCoords && radius\n ? getCircleBounds(subjectWellCoords, radius * METERS_IN_MILE)\n : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.getSource(RADIUS_SOURCE_ID).setData(\n subjectWellCoords && radius\n ? {\n type: 'Feature',\n properties: {},\n geometry: makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE),\n }\n : EMPTY_FEATURE_COLLECTION\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n const showTooltip = (well, isOffsetWell, isSubjectWell, coords) => {\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(WellTooltip(), {\n isViewOnly,\n well,\n color: get(formationColors, well.formation, '#BDBDBD'),\n isOffsetWell,\n isSubjectWell,\n isClickable,\n });\n ReactDOM.render(<>{popUpContent}</>, popUpContainer);\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({\n closeButton: false,\n offset: HIGHLIGHT_MARKER_SIZE,\n });\n }\n popupRef.current\n .setLngLat(toLngLat(coords))\n .setDOMContent(popUpContainer)\n .addTo(mapRef.current);\n };\n\n // NOTE: Subject well hover swaps the subject marker color\n useEffect(() => {\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return;\n }\n\n map.setPaintProperty(\n WELLS_LAYER_ID,\n 'circle-color',\n isSubjectWellHovered\n ? ['case', ['get', 'isSubjectWell'], HIGHLIGHT_WELL_COLOR, ['get', 'color']]\n : ['get', 'color']\n );\n }, [isSubjectWellHovered, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!wells || !offsetWellIds) {\n return undefined;\n }\n\n popupRef.current?.remove();\n\n const offsetWells = [];\n const unSelectedWells = [];\n wells.forEach(well => {\n if (well.id !== subjectWell?.id) {\n if (offsetWellIds.includes(well.id)) {\n offsetWells.push(well);\n } else {\n unSelectedWells.push(well);\n }\n }\n });\n const sortedWells = [...unSelectedWells, ...offsetWells, subjectWell];\n\n const features = [];\n const wellsBounds = new mapboxgl.LngLatBounds();\n wellByFeatureIdRef.current.clear();\n subjectFeatureIdRef.current = null;\n sortedWells.forEach((well, index) => {\n const coords = well?.topHole?.coordinates;\n\n if (coords && isValidCoordinates(coords)) {\n const isSubjectWell = subjectWell?.id === well.id;\n const isOffsetWell = offsetWellIds.includes(well.id) && !isSubjectWell;\n const color = isSubjectWell\n ? OFFSET_WELL_COLOR\n : get(formationColors, well.formation, '#BDBDBD');\n const opacity = isOffsetWell ? 0.7 : 0.3;\n\n features.push({\n type: 'Feature',\n id: index,\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: {\n color,\n opacity: isSubjectWell ? 1 : opacity,\n isSubjectWell,\n isOffsetWell,\n isActive: well.id === activeWellId && !isActiveWellIsSubjectWell,\n order: index,\n },\n });\n wellByFeatureIdRef.current.set(index, { well, coords, isOffsetWell, isSubjectWell });\n if (isSubjectWell) {\n subjectFeatureIdRef.current = index;\n }\n wellsBounds.extend(toLngLat(coords));\n }\n });\n wellsBoundsRef.current = features.length ? wellsBounds : null;\n\n const map = mapRef.current;\n if (!map || !isMapReady) {\n return undefined;\n }\n\n map.getSource(WELLS_SOURCE_ID).setData({ type: 'FeatureCollection', features });\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n hoveredFeatureIdRef.current = null;\n\n const handleMouseMove = e => {\n const feature = e.features?.[0];\n if (!feature || hoveredFeatureIdRef.current === feature.id) {\n return;\n }\n const entry = wellByFeatureIdRef.current.get(feature.id);\n if (!entry) {\n return;\n }\n\n hoveredFeatureIdRef.current = feature.id;\n map.getCanvas().style.cursor = 'pointer';\n\n // Highlight\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], feature.id]);\n showTooltip(entry.well, entry.isOffsetWell, entry.isSubjectWell, entry.coords);\n if (entry.isSubjectWell) {\n setIsSubjectWellHovered(true);\n }\n };\n\n const handleMouseLeave = e => {\n // NOTE: Leaflet cleared hover on leaving the ENLARGED highlight marker, so keep the\n // hover while the cursor is still over the hover halo (or another well marker)\n if (\n e?.point &&\n map.queryRenderedFeatures(e.point, { layers: [WELLS_LAYER_ID, WELLS_HOVER_LAYER_ID] })\n .length\n ) {\n return;\n }\n const wasSubjectWell =\n hoveredFeatureIdRef.current !== null &&\n hoveredFeatureIdRef.current === subjectFeatureIdRef.current;\n hoveredFeatureIdRef.current = null;\n map.getCanvas().style.cursor = '';\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n popupRef.current?.remove();\n if (wasSubjectWell) {\n setIsSubjectWellHovered(false);\n }\n };\n\n const handleClick = e => {\n if (isViewOnly) return;\n const entry = wellByFeatureIdRef.current.get(e.features?.[0]?.id);\n if (!entry) {\n return;\n }\n handleChangeOffsetWell(entry.well, !entry.isOffsetWell);\n };\n\n map.on('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.on('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.on('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.on('click', WELLS_LAYER_ID, handleClick);\n\n setTimeout(() => {\n if (radius < MAX_RADIUS && mapRef.current && radiusBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_LAYER_ID, handleMouseMove);\n map.off('mouseleave', WELLS_LAYER_ID, handleMouseLeave);\n map.off('mouseleave', WELLS_HOVER_LAYER_ID, handleMouseLeave);\n map.off('click', WELLS_LAYER_ID, handleClick);\n };\n }, [subjectWell, wells, offsetWellIds, activeWellId, isMapReady]);\n\n // NOTE: Subject Well Icon\n\n useEffect(() => {\n const map = mapRef.current;\n\n if (subjectIconRef.current) {\n subjectIconRef.current.remove();\n subjectIconRef.current = null;\n }\n\n if (!map || !subjectWellCoords) return;\n\n const isHighlighted = isSubjectWellHovered || isActiveWellIsSubjectWell;\n const icon = document.createElement('img');\n icon.src = isHighlighted ? SubjectHighlightWellIcon : SubjectWellIcon;\n const [iconWidth, iconHeight] = isHighlighted ? [70, 20] : [62, 12];\n const [anchorX, anchorY] = isHighlighted ? [35, 29] : [31, 25];\n icon.width = iconWidth;\n icon.height = iconHeight;\n\n icon.addEventListener('mouseover', () => {\n setIsSubjectWellHovered(true);\n\n // Highlight\n if (subjectFeatureIdRef.current !== null && map.getLayer(WELLS_HOVER_LAYER_ID)) {\n hoveredFeatureIdRef.current = subjectFeatureIdRef.current;\n map.setFilter(WELLS_HOVER_LAYER_ID, ['==', ['id'], subjectFeatureIdRef.current]);\n }\n showTooltip(subjectWell, false, true, subjectWellCoords);\n });\n\n icon.addEventListener('mouseout', () => {\n hoveredFeatureIdRef.current = null;\n if (map.getLayer(WELLS_HOVER_LAYER_ID)) {\n map.setFilter(WELLS_HOVER_LAYER_ID, NO_HOVER_FILTER);\n }\n popupRef.current?.remove();\n setIsSubjectWellHovered(false);\n });\n\n subjectIconRef.current = new mapboxgl.Marker({\n element: icon,\n anchor: 'center',\n // NOTE: Leaflet anchored the icon at [anchorX, anchorY] from its top-left corner\n offset: [iconWidth / 2 - anchorX, iconHeight / 2 - anchorY],\n })\n .setLngLat(toLngLat(subjectWellCoords))\n .addTo(map);\n }, [isSubjectWellHovered, subjectWellCoords, radius, subjectWell, isActiveWellIsSubjectWell]);\n\n // NOTE: Map Update\n useEffect(() => {\n if (radius > MAX_RADIUS) {\n mapRef.current?.setZoom(1);\n return;\n }\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusBoundsRef.current && radius) {\n mapRef.current.fitBounds(radiusBoundsRef.current, { padding: 5 });\n }\n } else if (mapRef.current && wellsBoundsRef.current) {\n mapRef.current.fitBounds(wellsBoundsRef.current);\n }\n if (subjectWellCoords && mapRef.current) {\n mapRef.current.easeTo({ center: toLngLat(subjectWellCoords), duration: 700 });\n }\n }, 500);\n }, [radius, subjectWell, subjectWellCoords]);\n\n const handleZoomIn = () => {\n mapRef.current?.setZoom(zoom + 1);\n };\n\n const handleZoomOut = () => {\n if (zoom > 1) {\n mapRef.current?.setZoom(zoom - 1);\n }\n };\n\n return (\n <div className={classNames(styles.mapView, classes.root)}>\n <div\n className={classNames(styles.mapMain, classes.map)}\n ref={containerRef}\n onDoubleClick={handleZoomIn}\n >\n <div className={styles.zoomGroup}>\n <Tooltip title={zoom < ZOOM_MAX_VALUE ? 'Zoom in' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MAX_VALUE,\n })}\n onClick={handleZoomIn}\n >\n <ZoomInIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n <Tooltip title={zoom > ZOOM_MIN_VALUE ? 'Zoom out' : ''} placement=\"left\">\n <div\n className={classNames(styles.zoomButton, {\n [styles.zoomDisabled]: zoom === ZOOM_MIN_VALUE,\n })}\n onClick={handleZoomOut}\n >\n <ZoomOutIcon className={styles.zoomInOutIcon} />\n </div>\n </Tooltip>\n </div>\n </div>\n </div>\n );\n};\n\nexport default OffsetWellMap;\n"],"names":["isValidCoordinates","mapbox","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","NO_HOVER_FILTER","toLngLat","_ref","_ref2","_slicedToArray","lat","makeCirclePolygon","_ref3","radiusMeters","_ref4","lng","points","degreesLng","Math","cos","PI","degreesLat","ring","i","theta","push","sin","coordinates","_ref7","isViewOnly","_ref7$subjectWell","subjectWell","wells","offsetWellIds","radius","handleChanageOffsetWell","_ref7$handleChangeOff","handleChangeOffsetWell","activeWellId","_ref7$isClickable","isClickable","_ref7$classes","classes","subjectWellCoords","useMemo","get","formationColors","getAllFormations","containerRef","useRef","mapRef","popupRef","radiusBoundsRef","wellsBoundsRef","subjectIconRef","wellByFeatureIdRef","Map","subjectFeatureIdRef","hoveredFeatureIdRef","useState","_useState2","_useState","isSubjectWellHovered","setIsSubjectWellHovered","isActiveWellIsSubjectWell","id","prevWells","usePreviousWells","_useState4","_useState3","isMapReady","setIsMapReady","_useState6","_useState5","zoom","setZoom","useEffect","IS_MAPBOX_ENABLED","map","mapboxgl","container","current","style","center","maxZoom","attributionControl","scrollZoom","doubleClickZoom","on","round","getZoom","addSource","data","addLayer","source","paint","filter","layout","remove","_ref5","_ref6","getSource","setData","properties","geometry","showTooltip","well","isOffsetWell","isSubjectWell","coords","popUpContainer","document","createElement","popUpContent","WellTooltip","color","formation","ReactDOM","render","_jsx","jsx","_Fragment","children","Popup","closeButton","offset","setLngLat","setDOMContent","addTo","setPaintProperty","_popupRef$current","offsetWells","unSelectedWells","forEach","includes","sortedWells","wellsBounds","LngLatBounds","clear","index","_well$topHole","topHole","opacity","isActive","order","set","extend","length","setFilter","handleMouseMove","e","_e$features","feature","entry","getCanvas","cursor","handleMouseLeave","_popupRef$current2","point","queryRenderedFeatures","layers","wasSubjectWell","handleClick","_e$features2","_e$features2$","setTimeout","fitBounds","padding","off","isHighlighted","icon","src","_ref8","_ref9","iconWidth","iconHeight","_ref10","_ref11","anchorX","anchorY","width","height","addEventListener","getLayer","_popupRef$current3","Marker","element","anchor","_mapRef$current","easeTo","duration","handleZoomIn","_mapRef$current2","className","classNames","styles","mapView","root","mapMain","ref","onDoubleClick","_jsxs","jsxs","zoomGroup","Tooltip","title","placement","zoomButton","_defineProperty","zoomDisabled","onClick","ZoomInIcon","zoomInOutIcon","_mapRef$current3","ZoomOutIcon"],"mappings":"kuBAoBQA,EAAuBC,EAAMA,OAA7BD,mBACFE,EAAiB,CAAC,WAAY,WAmB9BC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAClEC,EAAkB,CAAC,KAAM,CAAC,OAAQ,GAGlCC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAA,QAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EAGrCC,EAAoB,SAAHC,EAAgBC,GAIrC,IAJmE,IAAAC,EAAAL,EAAAA,QAAAG,EAAA,GAAzCF,EAAGI,EAAA,GAAEC,EAAGD,EAAA,GAAiBE,yDAAS,GACtDC,EAAaJ,GAAgB,OAASK,KAAKC,IAAKT,EAAMQ,KAAKE,GAAM,MACjEC,EAAaR,EAAe,OAC5BS,EAAO,GACJC,EAAI,EAAGA,GAAKP,EAAQO,GAAK,EAAG,CACnC,IAAMC,EAASD,EAAIP,EAAU,EAAIE,KAAKE,GACtCE,EAAKG,KAAK,CAACV,EAAME,EAAaC,KAAKC,IAAIK,GAAQd,EAAMW,EAAaH,KAAKQ,IAAIF,IAC7E,CACA,MAAO,CAAErB,KAAM,UAAWwB,YAAa,CAACL,GAC1C,iBAYsB,SAWhBM,GAAA,IAVJC,IAAAA,WAAUC,EAAAF,EACVG,YAAAA,aAAc,KAAID,EAClBE,IAAAA,MACAC,IAAAA,cACAC,IAAAA,OACAC,IAAAA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B,0BAO7C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),u=require("react-dom"),n=require("prop-types"),i=require("lodash"),o=require("@material-ui/core/styles"),a=require("./Map.css.js"),l=require("../../../../utils/index.js"),s=require("../../../../config/theme/index.js");require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/regenerator"),require("highcharts"),require("highcharts/highcharts-more"),require("highcharts/modules/solid-gauge"),require("highcharts/modules/heatmap"),require("highcharts/modules/boost"),require("highcharts/modules/exporting"),require("highcharts/modules/xrange"),require("highcharts/modules/dumbbell"),require("highcharts/modules/pattern-fill"),require("highcharts/modules/annotations"),require("highcharts-multicolor-series"),require("dompurify")
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),u=require("react-dom"),n=require("prop-types"),i=require("lodash"),o=require("@material-ui/core/styles"),a=require("./Map.css.js"),l=require("../../../../utils/index.js"),s=require("../../../../config/theme/index.js");require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/regenerator"),require("highcharts"),require("highcharts/highcharts-more"),require("highcharts/modules/solid-gauge"),require("highcharts/modules/heatmap"),require("highcharts/modules/boost"),require("highcharts/modules/exporting"),require("highcharts/modules/xrange"),require("highcharts/modules/dumbbell"),require("highcharts/modules/pattern-fill"),require("highcharts/modules/annotations"),require("highcharts-multicolor-series"),require("dompurify");var c=require("../../../../config/mapbox/index.js");require("@babel/runtime/helpers/createClass"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/assertThisInitialized"),require("@babel/runtime/helpers/inherits"),require("@babel/runtime/helpers/possibleConstructorReturn"),require("@babel/runtime/helpers/getPrototypeOf"),require("@babel/runtime/helpers/toArray"),require("@babel/runtime/helpers/toConsumableArray"),require("../../../../clients/subscriptions/constants.js"),require("../../../../clients/subscriptions.v1.js"),require("../../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../../config/extendNative.js"),require("../../../../config/mapboxGl/index.js"),require("mapbox-gl/dist/mapbox-gl.css");var d=require("react/jsx-runtime"),f=require("mapbox-gl");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=m(e),h=m(r),b=m(u),g=m(n),v=m(f);function y(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);r&&(u=u.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,u)}return t}function q(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?y(Object(t),!0).forEach((function(r){p.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):y(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var F=l.mapbox.isValidCoordinates,j=["#FF00FF","#F5BD80","#FF0000","#0080FF","#FF8000","#58ACFA","#FA58F4","#40FF00","#4B8A08","#40FF00","#D8F781"],x=[29.749907,-95.358421],w={type:"FeatureCollection",features:[]},O=function(e){var r=h.default(e,2),t=r[0];return[r[1],t]};function P(e){var r=e.subjectWell,u=e.wells,n=e.offsetWells,l=e.radius,f=e.subjectWellMarkerSize,m=e.wellMarkerSize,g=e.popUpFormatter,y=e.coordsDataPath,P=t.useRef(null),M=t.useRef(null),C=t.useRef(null),S=t.useRef(null),D=t.useRef(null),N=t.useRef(),B=t.useState(!1),k=h.default(B,2),E=k[0],I=k[1],L=t.useMemo((function(){return u.filter((function(e){return!r||r.id!==e.id}))}),[r,u]),W=t.useMemo((function(){return r&&i.get(r,y)}),[r,y]),A=t.useMemo((function(){var e=[],t=!1;L.forEach((function(u){"Null"===u.formation?t=!0:r&&r.formation===u.formation||e.includes(u.formation)||e.push(u.formation)}));var u=r?[r.formation].concat(i.sortBy(e)):i.sortBy(e);t&&!u.includes("Null")&&u.push("Null");var n=u.reduce((function(e,r,t){return q(q({},e),{},p.default({},r,j[t%j.length]))}),{});return[u,n]}),[r,L]),R=h.default(A,2),T=R[0],z=R[1];return t.useEffect((function(){if(c.IS_MAPBOX_ENABLED){M.current=new v.default.Map({container:P.current,style:"mapbox://styles/mapbox/dark-v9",center:O(x),zoom:1,attributionControl:!1,scrollZoom:!1}),M.current.addControl(new v.default.NavigationControl({showCompass:!1}),"bottom-right"),M.current.on("load",(function(){M.current.addSource("radius-circle",{type:"geojson",data:w}),M.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),M.current.addSource("wells",{type:"geojson",data:w}),M.current.addLayer({id:"wells",type:"circle",source:"wells",paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),I(!0)}));var e=M.current;return function(){e.remove(),M.current=null,C.current=null,S.current=null}}}),[]),t.useEffect((function(){if(M.current&&E){if(!W)return M.current.getSource("radius-circle").setData(w),void(C.current=null);var e=function(e,r){for(var t=h.default(e,2),u=t[0],n=t[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,o=[],a=r/(111320*Math.cos(u*Math.PI/180)),l=r/110574,s=0;s<=i;s+=1){var c=s/i*(2*Math.PI);o.push([n+a*Math.cos(c),u+l*Math.sin(c)])}return o}(W,1609.34*l);M.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[e]}}),C.current=e.reduce((function(e,r){return e.extend(r)}),new v.default.LngLatBounds)}}),[l,W,E]),t.useEffect((function(){var e;if(M.current&&E){var a=N.current;N.current=u,null===(e=D.current)||void 0===e||e.remove();var l=n.map((function(e){return e.id})),c=[],p={},h=new v.default.LngLatBounds;u.forEach((function(e){var t=i.get(e,y);if(t&&F(t)){var u=r&&r.id===e.id,n=l.includes(e.id),o=u?f:m,a=u||n?"#00FFFF":z[e.formation],s=u||n?1:.3;p[e.id]=e,h.extend(O(t)),c.push({type:"Feature",geometry:{type:"Point",coordinates:O(t)},properties:{wellId:e.id,radius:o,color:a,opacity:s}})}})),M.current.getSource("wells").setData({type:"FeatureCollection",features:c}),S.current=c.length?h:null;var q=M.current,j=null,x=function(e){q.getCanvas().style.cursor="pointer";var r=p[e.features[0].properties.wellId];if(r&&r.id!==j&&(j=r.id,g)){var u=document.createElement("div"),n=t.createElement(g,{well:r,color:z[r.formation]});b.default.render(d.jsx(o.MuiThemeProvider,{theme:s.darkTheme,children:n}),u),D.current||(D.current=new v.default.Popup({closeButton:!1,maxWidth:"none"})),D.current.setLngLat(O(i.get(r,y))).setDOMContent(u).addTo(q)}},w=function(){j=null,q.getCanvas().style.cursor=""};return q.on("mousemove","wells",x),q.on("mouseleave","wells",w),setTimeout((function(){M.current&&C.current&&u!==a&&M.current.fitBounds(C.current,{padding:5})}),500),function(){q.off("mousemove","wells",x),q.off("mouseleave","wells",w)}}}),[r,u,n,z,E]),t.useEffect((function(){setTimeout((function(){r?M.current&&C.current&&M.current.fitBounds(C.current,{padding:5}):M.current&&S.current&&M.current.fitBounds(S.current)}),500)}),[l,r,E]),d.jsxs("div",{className:a.map,children:[d.jsx("div",{className:a.mapMain,ref:P}),d.jsxs("div",{className:a.mapFooter,children:[n&&d.jsxs("div",{className:a.mapFooterItem,children:[d.jsx("div",{className:a.mapFooterItemSquare,style:{backgroundColor:"#00FFFF"}}),d.jsx("div",{className:a.mapFooterItemLabel,children:"Selected Offset Wells"})]}),T.map((function(e){return d.jsxs("div",{className:a.mapFooterItem,children:[d.jsx("div",{className:a.mapFooterItemSquare,style:{backgroundColor:z[e]}}),d.jsx("div",{className:a.mapFooterItemLabel,children:e})]},e)}))]})]})}P.propTypes={subjectWell:g.default.shape({id:g.default.number,formation:g.default.string}),wells:g.default.arrayOf(g.default.shape({})).isRequired,offsetWells:g.default.arrayOf(g.default.shape({})),radius:g.default.number.isRequired,subjectWellMarkerSize:g.default.number,wellMarkerSize:g.default.number,popUpFormatter:g.default.func,coordsDataPath:g.default.string},P.defaultProps={subjectWell:null,subjectWellMarkerSize:10,wellMarkerSize:5,popUpFormatter:null,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var M=t.memo(P);module.exports=M;
|
|
2
2
|
//# sourceMappingURL=Map.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Map.js","sources":["../../../../../../src/components/OffsetWellPickerV2/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get, sortBy } from 'lodash';\nimport { MuiThemeProvider } from '@material-ui/core/styles';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport { theme } from '~/config';\nimport mapboxgl from '~/config/mapboxGl';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 10;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#00FFFF';\nconst COLORS = [\n '#FF00FF',\n '#F5BD80',\n '#FF0000',\n '#0080FF',\n '#FF8000',\n '#58ACFA',\n '#FA58F4',\n '#40FF00',\n '#4B8A08',\n '#40FF00',\n '#D8F781',\n];\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n popUpFormatter,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const radiusCircleBoundsRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const restWells = useMemo(() => {\n return wells.filter(well => !subjectWell || subjectWell.id !== well.id);\n }, [subjectWell, wells]);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Get well marker colors according to its target formation\n const [formations, colorDict] = useMemo(() => {\n // NOTE: Determine well marker colors\n const restFormations = [];\n let hasNullFormation = false;\n\n restWells.forEach(well => {\n if (well.formation === 'Null') {\n hasNullFormation = true;\n } else if (\n (!subjectWell || subjectWell.formation !== well.formation) &&\n !restFormations.includes(well.formation)\n ) {\n restFormations.push(well.formation);\n }\n });\n\n const sortedFormations = subjectWell\n ? [subjectWell.formation].concat(sortBy(restFormations))\n : sortBy(restFormations);\n\n if (hasNullFormation && !sortedFormations.includes('Null')) {\n sortedFormations.push('Null');\n }\n\n const colors = sortedFormations.reduce(\n (result, item, idx) => ({\n ...result,\n [item]: COLORS[idx % COLORS.length],\n }),\n {}\n );\n\n return [sortedFormations, colors];\n }, [subjectWell, restWells]);\n\n // NOTE: Initialize map\n useEffect(() => {\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack)\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n radiusCircleBoundsRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n radiusCircleBoundsRef.current = null;\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n radiusCircleBoundsRef.current = ring.reduce(\n (bounds, coord) => bounds.extend(coord),\n new mapboxgl.LngLatBounds()\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const color = isWellSubject || isWellOffset ? OFFSET_WELL_COLOR : colorDict[well.formation];\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, color, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n if (popUpFormatter) {\n // Container to put React generated content in.\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(popUpFormatter, {\n well,\n color: colorDict[well.formation],\n });\n // NOTE: Custom popup may have buttons\n ReactDOM.render(\n <MuiThemeProvider theme={theme.darkTheme}>{popUpContent}</MuiThemeProvider>,\n popUpContainer\n );\n\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current\n .setLngLat(toLngLat(get(well, coordsDataPath)))\n .setDOMContent(popUpContainer)\n .addTo(map);\n }\n };\n\n const handleMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && radiusCircleBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, colorDict, isMapReady]);\n\n useEffect(() => {\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusCircleBoundsRef.current) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, {\n padding: 5,\n });\n }\n } else if (mapRef.current && markersBoundsRef.current) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n }, [radius, subjectWell, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n\n <div className={styles.mapFooter}>\n {offsetWells && (\n <div className={styles.mapFooterItem}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: OFFSET_WELL_COLOR }}\n />\n <div className={styles.mapFooterItemLabel}>Selected Offset Wells</div>\n </div>\n )}\n\n {formations.map(item => (\n <div className={styles.mapFooterItem} key={item}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: colorDict[item] }}\n />\n <div className={styles.mapFooterItemLabel}>{item}</div>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n popUpFormatter: PropTypes.func,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n popUpFormatter: null,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","COLORS","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref5","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","popUpFormatter","coordsDataPath","mapContainerRef","useRef","mapRef","radiusCircleBoundsRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","restWells","useMemo","filter","well","id","subjectWellCoords","get","restFormations","hasNullFormation","forEach","formation","includes","push","sortedFormations","concat","sortBy","colors","reduce","result","item","idx","length","_useMemo2","_useMemo","formations","colorDict","useEffect","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","source","paint","map","remove","getSource","setData","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","sin","makeCirclePolygon","geometry","coordinates","bounds","coord","extend","LngLatBounds","_popupRef$current","prevWells","offsetWellIds","wellsById","coords","isWellSubject","isWellOffset","r","color","opacity","properties","wellId","hoveredWellId","handleMouseMove","e","getCanvas","cursor","popUpContainer","document","createElement","popUpContent","ReactDOM","render","_jsx","jsx","MuiThemeProvider","theme","darkTheme","children","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseLeave","setTimeout","fitBounds","padding","off","_jsxs","className","styles","mapMain","ref","jsxs","mapFooter","mapFooterItem","mapFooterItemSquare","backgroundColor","mapFooterItemLabel","propTypes","PropTypes","shape","number","string","arrayOf","isRequired","func","defaultProps","memo"],"mappings":"w1EAaA,IAAQA,EAAuBC,EAAMA,OAA7BD,mBAOFE,EAAS,CACb,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WAGIC,EAAiB,CAAC,WAAY,WAI9BC,EAA2B,CAAEC,KAAM,o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A,CAAKC,UAAWC,EAAOK,cAAcnB,SACnC,CAAAL,EAAAC,IAAA,MAAA,CACEiB,UAAWC,EAAOM,oBAClBvF,MAAO,CAAEwF,gBAAiB9F,EAAUN,MAEtC0E,EAAAC,IAAA,MAAA,CAAKiB,UAAWC,EAAOQ,mBAAmBtB,SAAE/E,MALHA,EAMrC,SAKhB,CAEAzC,EAAS+I,UAAY,CACnB7I,YAAa8I,EAAS,QAACC,MAAM,CAC3BvH,GAAIsH,EAAS,QAACE,OACdlH,UAAWgH,EAAS,QAACG,SAEvBhJ,MAAO6I,EAAS,QAACI,QAAQJ,EAAAA,QAAUC,MAAM,CAAA,IAAKI,WAC9CjJ,YAAa4I,EAAS,QAACI,QAAQJ,EAAS,QAACC,MAAM,CAAE,IACjD5I,OAAQ2I,EAAAA,QAAUE,OAAOG,WACzB/I,sBAAuB0I,EAAS,QAACE,OACjC3I,eAAgByI,EAAS,QAACE,OAC1B1I,eAAgBwI,EAAS,QAACM,KAC1B7I,eAAgBuI,EAAS,QAACG,QAG5BnJ,EAASuJ,aAAe,CACtBrJ,YAAa,KACbI,sBA7UuC,GA8UvCC,eA7U+B,EA8U/BC,eAAgB,KAChBC,eAAgB,gCAChBL,YAAa,MAGf,IAAeoJ,EAAAA,EAAAA,KAAKxJ"}
|
|
1
|
+
{"version":3,"file":"Map.js","sources":["../../../../../../src/components/OffsetWellPickerV2/components/Map/Map.js"],"sourcesContent":["import { createElement, memo, useRef, useEffect, useMemo, useState } from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { get, sortBy } from 'lodash';\nimport { MuiThemeProvider } from '@material-ui/core/styles';\n\nimport styles from './Map.css';\n\nimport { mapbox } from '~/utils';\nimport { theme } from '~/config';\nimport mapboxgl from '~/config/mapboxGl';\nimport { IS_MAPBOX_ENABLED } from '~/config/mapbox';\nimport 'mapbox-gl/dist/mapbox-gl.css';\n\nconst { isValidCoordinates } = mapbox;\n\nconst RADIUS_CIRCLE_COLOR = '#03BCD4';\nconst METERS_IN_MILE = 1609.34;\nconst DEFAULT_SUBJECT_WELL_MARKER_SIZE = 10;\nconst DEFAULT_WELL_MARKER_SIZE = 5;\nconst OFFSET_WELL_COLOR = '#00FFFF';\nconst COLORS = [\n '#FF00FF',\n '#F5BD80',\n '#FF0000',\n '#0080FF',\n '#FF8000',\n '#58ACFA',\n '#FA58F4',\n '#40FF00',\n '#4B8A08',\n '#40FF00',\n '#D8F781',\n];\n\nconst DEFAULT_COORDS = [29.749907, -95.358421]; // TX coordinates\n\nconst RADIUS_CIRCLE_ID = 'radius-circle';\nconst WELLS_ID = 'wells';\nconst EMPTY_FEATURE_COLLECTION = { type: 'FeatureCollection', features: [] };\n\nconst toLngLat = ([lat, lng]) => [lng, lat];\n\n// NOTE: mapbox-gl has no geographic-radius circle primitive, so approximate it with a polygon\nconst makeCirclePolygon = ([lat, lng], radiusMeters, points = 64) => {\n const ring = [];\n const distanceX = radiusMeters / (111320 * Math.cos((lat * Math.PI) / 180));\n const distanceY = radiusMeters / 110574;\n for (let i = 0; i <= points; i += 1) {\n const theta = (i / points) * (2 * Math.PI);\n ring.push([lng + distanceX * Math.cos(theta), lat + distanceY * Math.sin(theta)]);\n }\n return ring;\n};\n\n// eslint-disable-next-line no-unused-vars\nfunction WellsMap({\n subjectWell,\n wells,\n offsetWells,\n radius,\n subjectWellMarkerSize,\n wellMarkerSize,\n popUpFormatter,\n coordsDataPath,\n}) {\n const mapContainerRef = useRef(null);\n const mapRef = useRef(null);\n const radiusCircleBoundsRef = useRef(null);\n const markersBoundsRef = useRef(null);\n const popupRef = useRef(null);\n const prevWellsRef = useRef();\n const [isMapReady, setIsMapReady] = useState(false);\n\n const restWells = useMemo(() => {\n return wells.filter(well => !subjectWell || subjectWell.id !== well.id);\n }, [subjectWell, wells]);\n\n const subjectWellCoords = useMemo(() => {\n return subjectWell && get(subjectWell, coordsDataPath);\n }, [subjectWell, coordsDataPath]);\n\n // NOTE: Get well marker colors according to its target formation\n const [formations, colorDict] = useMemo(() => {\n // NOTE: Determine well marker colors\n const restFormations = [];\n let hasNullFormation = false;\n\n restWells.forEach(well => {\n if (well.formation === 'Null') {\n hasNullFormation = true;\n } else if (\n (!subjectWell || subjectWell.formation !== well.formation) &&\n !restFormations.includes(well.formation)\n ) {\n restFormations.push(well.formation);\n }\n });\n\n const sortedFormations = subjectWell\n ? [subjectWell.formation].concat(sortBy(restFormations))\n : sortBy(restFormations);\n\n if (hasNullFormation && !sortedFormations.includes('Null')) {\n sortedFormations.push('Null');\n }\n\n const colors = sortedFormations.reduce(\n (result, item, idx) => ({\n ...result,\n [item]: COLORS[idx % COLORS.length],\n }),\n {}\n );\n\n return [sortedFormations, colors];\n }, [subjectWell, restWells]);\n\n // NOTE: Initialize map\n useEffect(() => {\n if (!IS_MAPBOX_ENABLED) return undefined;\n\n mapRef.current = new mapboxgl.Map({\n container: mapContainerRef.current,\n style: 'mapbox://styles/mapbox/dark-v9',\n center: toLngLat(DEFAULT_COORDS),\n zoom: 1,\n attributionControl: false,\n scrollZoom: false,\n });\n\n mapRef.current.addControl(\n new mapboxgl.NavigationControl({ showCompass: false }),\n 'bottom-right'\n );\n\n // NOTE: Sources/layers can only be added once the style has loaded.\n // The radius circle layer is added first so well markers render above it (was bringToBack)\n mapRef.current.on('load', () => {\n mapRef.current.addSource(RADIUS_CIRCLE_ID, {\n type: 'geojson',\n data: EMPTY_FEATURE_COLLECTION,\n });\n mapRef.current.addLayer({\n id: RADIUS_CIRCLE_ID,\n type: 'fill',\n source: RADIUS_CIRCLE_ID,\n paint: {\n 'fill-color': RADIUS_CIRCLE_COLOR,\n 'fill-opacity': 0.2,\n },\n });\n\n mapRef.current.addSource(WELLS_ID, { type: 'geojson', data: EMPTY_FEATURE_COLLECTION });\n mapRef.current.addLayer({\n id: WELLS_ID,\n type: 'circle',\n source: WELLS_ID,\n paint: {\n 'circle-radius': ['get', 'radius'],\n 'circle-color': ['get', 'color'],\n 'circle-opacity': ['get', 'opacity'],\n },\n });\n\n setIsMapReady(true);\n });\n\n const map = mapRef.current;\n return () => {\n map.remove();\n mapRef.current = null;\n radiusCircleBoundsRef.current = null;\n markersBoundsRef.current = null;\n };\n }, []);\n\n // NOTE: Radius circle\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return;\n }\n\n if (!subjectWellCoords) {\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData(EMPTY_FEATURE_COLLECTION);\n radiusCircleBoundsRef.current = null;\n return;\n }\n\n const ring = makeCirclePolygon(subjectWellCoords, radius * METERS_IN_MILE);\n mapRef.current.getSource(RADIUS_CIRCLE_ID).setData({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [ring] },\n });\n radiusCircleBoundsRef.current = ring.reduce(\n (bounds, coord) => bounds.extend(coord),\n new mapboxgl.LngLatBounds()\n );\n }, [radius, subjectWellCoords, isMapReady]);\n\n // NOTE: Well markers\n useEffect(() => {\n if (!mapRef.current || !isMapReady) {\n return undefined;\n }\n\n const prevWells = prevWellsRef.current;\n prevWellsRef.current = wells;\n\n popupRef.current?.remove();\n\n const offsetWellIds = offsetWells.map(well => well.id);\n\n const features = [];\n const wellsById = {};\n const bounds = new mapboxgl.LngLatBounds();\n wells.forEach(well => {\n const coords = get(well, coordsDataPath);\n\n if (coords && isValidCoordinates(coords)) {\n const isWellSubject = subjectWell && subjectWell.id === well.id;\n const isWellOffset = offsetWellIds.includes(well.id);\n const r = isWellSubject ? subjectWellMarkerSize : wellMarkerSize;\n const color = isWellSubject || isWellOffset ? OFFSET_WELL_COLOR : colorDict[well.formation];\n const opacity = isWellSubject || isWellOffset ? 1 : 0.3;\n\n wellsById[well.id] = well;\n bounds.extend(toLngLat(coords));\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: toLngLat(coords) },\n properties: { wellId: well.id, radius: r, color, opacity },\n });\n }\n });\n\n mapRef.current.getSource(WELLS_ID).setData({ type: 'FeatureCollection', features });\n markersBoundsRef.current = features.length ? bounds : null;\n\n const map = mapRef.current;\n let hoveredWellId = null;\n\n const handleMouseMove = e => {\n map.getCanvas().style.cursor = 'pointer';\n\n const well = wellsById[e.features[0].properties.wellId];\n if (!well || well.id === hoveredWellId) {\n return;\n }\n hoveredWellId = well.id;\n\n if (popUpFormatter) {\n // Container to put React generated content in.\n const popUpContainer = document.createElement('div');\n const popUpContent = createElement(popUpFormatter, {\n well,\n color: colorDict[well.formation],\n });\n // NOTE: Custom popup may have buttons\n ReactDOM.render(\n <MuiThemeProvider theme={theme.darkTheme}>{popUpContent}</MuiThemeProvider>,\n popUpContainer\n );\n\n if (!popupRef.current) {\n popupRef.current = new mapboxgl.Popup({ closeButton: false, maxWidth: 'none' });\n }\n popupRef.current\n .setLngLat(toLngLat(get(well, coordsDataPath)))\n .setDOMContent(popUpContainer)\n .addTo(map);\n }\n };\n\n const handleMouseLeave = () => {\n hoveredWellId = null;\n map.getCanvas().style.cursor = '';\n };\n\n map.on('mousemove', WELLS_ID, handleMouseMove);\n map.on('mouseleave', WELLS_ID, handleMouseLeave);\n\n setTimeout(() => {\n if (mapRef.current && radiusCircleBoundsRef.current && wells !== prevWells) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, { padding: 5 });\n }\n }, 500);\n\n return () => {\n map.off('mousemove', WELLS_ID, handleMouseMove);\n map.off('mouseleave', WELLS_ID, handleMouseLeave);\n };\n }, [subjectWell, wells, offsetWells, colorDict, isMapReady]);\n\n useEffect(() => {\n setTimeout(() => {\n if (subjectWell) {\n if (mapRef.current && radiusCircleBoundsRef.current) {\n mapRef.current.fitBounds(radiusCircleBoundsRef.current, {\n padding: 5,\n });\n }\n } else if (mapRef.current && markersBoundsRef.current) {\n mapRef.current.fitBounds(markersBoundsRef.current);\n }\n }, 500);\n }, [radius, subjectWell, isMapReady]);\n\n return (\n <div className={styles.map}>\n <div className={styles.mapMain} ref={mapContainerRef} />\n\n <div className={styles.mapFooter}>\n {offsetWells && (\n <div className={styles.mapFooterItem}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: OFFSET_WELL_COLOR }}\n />\n <div className={styles.mapFooterItemLabel}>Selected Offset Wells</div>\n </div>\n )}\n\n {formations.map(item => (\n <div className={styles.mapFooterItem} key={item}>\n <div\n className={styles.mapFooterItemSquare}\n style={{ backgroundColor: colorDict[item] }}\n />\n <div className={styles.mapFooterItemLabel}>{item}</div>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nWellsMap.propTypes = {\n subjectWell: PropTypes.shape({\n id: PropTypes.number,\n formation: PropTypes.string,\n }),\n wells: PropTypes.arrayOf(PropTypes.shape({})).isRequired,\n offsetWells: PropTypes.arrayOf(PropTypes.shape({})),\n radius: PropTypes.number.isRequired,\n subjectWellMarkerSize: PropTypes.number,\n wellMarkerSize: PropTypes.number,\n popUpFormatter: PropTypes.func,\n coordsDataPath: PropTypes.string,\n};\n\nWellsMap.defaultProps = {\n subjectWell: null,\n subjectWellMarkerSize: DEFAULT_SUBJECT_WELL_MARKER_SIZE,\n wellMarkerSize: DEFAULT_WELL_MARKER_SIZE,\n popUpFormatter: null,\n coordsDataPath: 'settings.top_hole.coordinates',\n offsetWells: null,\n};\n\nexport default memo(WellsMap);\n"],"names":["isValidCoordinates","mapbox","COLORS","DEFAULT_COORDS","EMPTY_FEATURE_COLLECTION","type","features","toLngLat","_ref","_ref2","_slicedToArray","lat","WellsMap","_ref5","subjectWell","wells","offsetWells","radius","subjectWellMarkerSize","wellMarkerSize","popUpFormatter","coordsDataPath","mapContainerRef","useRef","mapRef","radiusCircleBoundsRef","markersBoundsRef","popupRef","prevWellsRef","useState","_useState2","_useState","isMapReady","setIsMapReady","restWells","useMemo","filter","well","id","subjectWellCoords","get","restFormations","hasNullFormation","forEach","formation","includes","push","sortedFormations","concat","sortBy","colors","reduce","result","item","idx","length","_useMemo2","_useMemo","formations","colorDict","useEffect","IS_MAPBOX_ENABLED","current","mapboxgl","Map","container","style","center","zoom","attributionControl","scrollZoom","addControl","NavigationControl","showCompass","on","addSource","data","addLayer","source","paint","map","remove","getSource","setData","ring","_ref3","radiusMeters","_ref4","lng","points","distanceX","Math","cos","PI","distanceY","i","theta","sin","makeCirclePolygon","geometry","coordinates","bounds","coord","extend","LngLatBounds","_popupRef$current","prevWells","offsetWellIds","wellsById","coords","isWellSubject","isWellOffset","r","color","opacity","properties","wellId","hoveredWellId","handleMouseMove","e","getCanvas","cursor","popUpContainer","document","createElement","popUpContent","ReactDOM","render","_jsx","jsx","MuiThemeProvider","theme","darkTheme","children","Popup","closeButton","maxWidth","setLngLat","setDOMContent","addTo","handleMouseLeave","setTimeout","fitBounds","padding","off","_jsxs","className","styles","mapMain","ref","jsxs","mapFooter","mapFooterItem","mapFooterItemSquare","backgroundColor","mapFooterItemLabel","propTypes","PropTypes","shape","number","string","arrayOf","isRequired","func","defaultProps","memo"],"mappings":"44EAcA,IAAQA,EAAuBC,EAAMA,OAA7BD,mBAOFE,EAAS,CACb,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WAGIC,EAAiB,CAAC,WAAY,WAI9BC,EAA2B,CAAEC,KAAM,oBAAqBC,SAAU,IAElEC,EAAW,SAAHC,GAAA,IAAAC,EAAAC,EAAAA,QAAAF,EAAA,GAAKG,EAAGF,EAAA,GAAK,MAAM,CAANA,EAAA,GAAYE,EAAI,EAe3C,SAASC,EASNC,GAAA,IARDC,IAAAA,YACAC,IAAAA,MACAC,IAAAA,YACAC,IAAAA,OACAC,IAAAA,sBACAC,IAAAA,eACAC,IAAAA,eACAC,IAAAA,eAEMC,EAAkBC,SAAO,MACzBC,EAASD,SAAO,MAChBE,EAAwBF,SAAO,MAC/BG,EAAmBH,SAAO,MAC1BI,EAAWJ,SAAO,MAClBK,EAAeL,EAAAA,SACeM,EAAAA,EAAQA,UAAC,GAAMC,EAAApB,EAAAA,QAAAqB,EAAA,GAA5CC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAE1BI,EAAYC,EAAAA,SAAQ,WACxB,OAAOpB,EAAMqB,QAAO,SAAAC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AuB2I,EAAS,QAACE,OACjC5I,eAAgB0I,EAAS,QAACE,OAC1B3I,eAAgByI,EAAS,QAACM,KAC1B9I,eAAgBwI,EAAS,QAACG,QAG5BpJ,EAASwJ,aAAe,CACtBtJ,YAAa,KACbI,sBA/UuC,GAgVvCC,eA/U+B,EAgV/BC,eAAgB,KAChBC,eAAgB,gCAChBL,YAAa,MAGf,IAAeqJ,EAAAA,EAAAA,KAAKzJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react"),t=require("react-dom"),u=require("prop-types"),n=require("lodash"),o=require("./Map.css.js"),l=require("../../../../../../utils/index.js");require("../../../../../../config/mapboxGl/index.js")
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react"),t=require("react-dom"),u=require("prop-types"),n=require("lodash"),o=require("./Map.css.js"),l=require("../../../../../../utils/index.js");require("../../../../../../config/mapboxGl/index.js");var a=require("../../../../../../config/mapbox/index.js");require("mapbox-gl/dist/mapbox-gl.css");var i=require("react/jsx-runtime"),c=require("mapbox-gl");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(e),f=s(t),p=s(u),m=s(c),g=l.mapbox.isValidCoordinates,v=[29.749907,-95.358421],y={type:"FeatureCollection",features:[]},h=function(e){var r=d.default(e,2),t=r[0];return[r[1],t]};function w(e){var t=e.open,u=e.subjectWell,l=e.wells,c=e.offsetWells,s=e.radius,p=e.formationColors,w=e.popUpFormatter,b=e.coordsDataPath,x=e.onAddOffsetWell,q=e.onDeleteOffsetWell,D=r.useRef(null),B=r.useRef(),j=r.useRef(null),C=r.useRef(null),F=r.useRef(null),R=r.useRef(),M=r.useState(!1),W=d.default(M,2),E=W[0],P=W[1],L=r.useMemo((function(){return u&&n.get(u,b)}),[u,b]);return r.useEffect((function(){a.IS_MAPBOX_ENABLED&&t&&!B.current&&(B.current=new m.default.Map({container:D.current,style:"mapbox://styles/mapbox/dark-v9",center:h(v),zoom:1,attributionControl:!1,scrollZoom:!1}),B.current.addControl(new m.default.NavigationControl({showCompass:!1}),"bottom-right"),B.current.on("load",(function(){B.current.addSource("radius-circle",{type:"geojson",data:y}),B.current.addLayer({id:"radius-circle",type:"fill",source:"radius-circle",paint:{"fill-color":"#03BCD4","fill-opacity":.2}}),B.current.addSource("wells",{type:"geojson",data:y}),B.current.addLayer({id:"wells",type:"circle",source:"wells",layout:{"circle-sort-key":["get","sortKey"]},paint:{"circle-radius":["get","radius"],"circle-color":["get","color"],"circle-opacity":["get","opacity"]}}),P(!0)})))}),[t]),r.useEffect((function(){return function(){B.current&&(B.current.remove(),B.current=null,j.current=null,C.current=null)}}),[]),r.useEffect((function(){if(B.current&&E&&t){if(!L)return B.current.getSource("radius-circle").setData(y),void(j.current=null);var e=function(e,r){for(var t=d.default(e,2),u=t[0],n=t[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,l=[],a=r/(111320*Math.cos(u*Math.PI/180)),i=r/110574,c=0;c<=o;c+=1){var s=c/o*(2*Math.PI);l.push([n+a*Math.cos(s),u+i*Math.sin(s)])}return l}(L,1609.34*s);B.current.getSource("radius-circle").setData({type:"Feature",geometry:{type:"Polygon",coordinates:[e]}}),j.current=e.reduce((function(e,r){return e.extend(r)}),new m.default.LngLatBounds)}}),[s,L,t,E]),r.useEffect((function(){if(B.current&&E&&t){var e=R.current;R.current=l;var o=c.map((function(e){return e.id})),a=n.sortBy(l,(function(e){return o.includes(e.id)})),s=[],d={},v=new m.default.LngLatBounds;a.forEach((function(e){var r=n.get(e,b);if(r&&g(r)){var t=u&&u.id===e.id,l=o.includes(e.id),a=t?10:5,i=t||l?"#00FFFF":n.get(p,e.formation,"#BDBDBD"),c=t||l?1:.3;d[e.id]=e,v.extend(h(r)),s.push({type:"Feature",geometry:{type:"Point",coordinates:h(r)},properties:{wellId:e.id,radius:a,color:i,opacity:c,sortKey:l?1:0}})}})),B.current.getSource("wells").setData({type:"FeatureCollection",features:s}),C.current=s.length?v:null;var y=B.current,D=null,M=function(e){y.getCanvas().style.cursor="pointer";var t=d[e.features[0].properties.wellId];if(t&&t.id!==D&&(D=t.id,w)){var u=document.createElement("div"),o=r.createElement(w,{well:t,color:n.get(p,t.formation,"#BDBDBD")});f.default.render(i.jsx(i.Fragment,{children:o}),u),F.current||(F.current=new m.default.Popup({closeButton:!1,maxWidth:"none"})),F.current.setLngLat(h(n.get(t,b))).setDOMContent(u).addTo(y)}},W=function(){var e;D=null,y.getCanvas().style.cursor="",null===(e=F.current)||void 0===e||e.remove()},P=function(e){var r=e.features[0].properties.wellId,t=u&&u.id===r;o.includes(r)&&!t?q(r):x(r)};return y.on("mousemove","wells",M),y.on("mouseleave","wells",W),y.on("click","wells",P),setTimeout((function(){B.current&&j.current&&l!==e&&B.current.fitBounds(j.current,{padding:5})}),500),function(){y.off("mousemove","wells",M),y.off("mouseleave","wells",W),y.off("click","wells",P)}}}),[u,l,c,t,E]),r.useEffect((function(){t&&setTimeout((function(){u?B.current&&j.current&&B.current.fitBounds(j.current,{padding:5}):B.current&&C.current&&B.current.fitBounds(C.current)}),500)}),[s,u,t,E]),i.jsx("div",{className:o.map,children:i.jsx("div",{className:o.mapMain,ref:D})})}w.propTypes={open:p.default.bool.isRequired,subjectWell:p.default.shape({id:p.default.number,formation:p.default.string}),wells:p.default.arrayOf(p.default.shape({})).isRequired,offsetWells:p.default.arrayOf(p.default.shape({})),radius:p.default.number.isRequired,formationColors:p.default.shape({}).isRequired,popUpFormatter:p.default.func,coordsDataPath:p.default.string,onAddOffsetWell:p.default.func.isRequired,onDeleteOffsetWell:p.default.func.isRequired},w.defaultProps={subjectWell:null,popUpFormatter:null,coordsDataPath:"settings.top_hole.coordinates",offsetWells:null};var b=r.memo(w);module.exports=b;
|
|
2
2
|
//# sourceMappingURL=Map.js.map
|