Skip to content

Commit

Permalink
added flowlines
Browse files Browse the repository at this point in the history
  • Loading branch information
romer8 committed Jun 10, 2024
1 parent 0f2c0c3 commit b2aabc1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
27 changes: 26 additions & 1 deletion reactapp/lib/layersData.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,30 @@ const sldCatchmentStyle = `<?xml version="1.0" encoding="ISO-8859-1"?>
</NamedLayer>
</StyledLayerDescriptor>`

export { initialLayersArray,sldCatchmentStyle }
const sldFlowPathsStyle = `<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>nextgen:flowpaths</Name>
<UserStyle>
<FeatureTypeStyle>
<Rule>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#87CEEB</CssParameter>
<CssParameter name="stroke-width">2</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>`


export { initialLayersArray,sldCatchmentStyle,sldFlowPathsStyle }

31 changes: 30 additions & 1 deletion reactapp/lib/mapUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Text,
} from 'ol/style';
import { VectorSourceLayer } from 'features/Map/lib/source/sources';
import { sldCatchmentStyle } from './layersData';
import { sldCatchmentStyle,sldFlowPathsStyle } from './layersData';

const image = new CircleStyle({
radius: 5,
Expand Down Expand Up @@ -202,6 +202,34 @@ let makeCatchmentLayer = (catchmentLayersURL) =>{
}
}

let makeFlowPathsLayer = (flowPathsLayersURL) =>{
return {
layerType: 'OlTileLayer',
options:
{
sourceType: 'WMSTile',
url: flowPathsLayersURL,
// all the params for the source goes here
params: {
LAYERS: 'nextgen:flowpaths',
Tiled: true,
SLD_BODY: sldFlowPathsStyle
},
// the rest of the attributes are for the definition of the layer
name: "Flowpaths Layer",
zIndex: 2,
source:{
serverType: 'geoserver',
crossOrigin: 'anonymous'
}

},

}
}



const customForEachLayerAtPixelLayerFilter = (layer) =>{
return layer.get('name') !== 'baseMapLayer'
// return layer.get('events') && layer.get('events').length > 0 && layer.get('events').findIndex(event => event.type === 'click') > -1
Expand Down Expand Up @@ -313,6 +341,7 @@ const displayFeatureInfo = (event,layer,hydroFabricActions) => {
export {
makeNexusLayerParams,
makeCatchmentLayer,
makeFlowPathsLayer,
displayFeatureInfo,
displayFeatureInfoWMS,
customForEachLayerAtPixelLayerFilter,
Expand Down
10 changes: 10 additions & 0 deletions reactapp/views/ngiab/map_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { initialLayersArray } from 'lib/layersData';
import {
makeNexusLayerParams,
makeCatchmentLayer,
makeFlowPathsLayer,
createClusterVectorLayer
} from 'lib/mapUtils';
import LoadingAnimation from 'components/loader/LoadingAnimation';
Expand All @@ -30,6 +31,12 @@ const MapView = (props) => {
const catchmentLayersURL = 'http://localhost:8181/geoserver/wms';
return makeCatchmentLayer(catchmentLayersURL);
},[])

const flowPathsLayerCallBack = useCallback(() => {
const flowPathsLayersURL = 'http://localhost:8181/geoserver/wms';
return makeFlowPathsLayer(flowPathsLayersURL);
},[])

const onPointerMoveLayersEventCallback = useCallback((event) => {
return onPointerMoveLayersEvent(event)
},[]);
Expand Down Expand Up @@ -61,16 +68,19 @@ const MapView = (props) => {
// Define the parameters for the layer
var nexusLayerParams = nexusLayerParamsCallBack();
var catchmentLayer = catchmentLayerCallBack();
var flowPathsLayer = flowPathsLayerCallBack();

nexusLayerParams['geojsonLayer']=response.geojson;

const nexusClusterLayer = createClusterVectorLayer(nexusLayerParams);


const NexusExtent = nexusClusterLayer.options.params.source.getExtent();

mapActions.addLayer(nexusClusterLayer);
mapActions.set_extent(NexusExtent);
mapActions.addLayer(catchmentLayer);
mapActions.addLayer(flowPathsLayer);

}).catch(error => {
console.log(error)
Expand Down

0 comments on commit b2aabc1

Please sign in to comment.