Skip to content

Commit

Permalink
Change Geoserver to tileserver
Browse files Browse the repository at this point in the history
  • Loading branch information
jhanninen committed Sep 3, 2024
1 parent 36fd117 commit 9354f34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
33 changes: 16 additions & 17 deletions src/components/map/layers/NetworkLayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import VectorGridLayer from './VectorGridLayer';
import * as s from './networkLayers.scss';
import { INodePopupData } from './popups/NodePopup';

enum GeoserverLayer {
Node = 'solmu',
Link = 'linkki',
Point = 'piste',
enum TileserverLayer {
Link = 'linkki_view',
Point = 'piste_view',
}

interface INetworkLayersProps {
Expand All @@ -40,9 +39,9 @@ interface ILinkProperties {
lnkloppusolmu: string;
}

function getGeoServerUrl(layerName: string) {
const GEOSERVER_URL = constants.GEOSERVER_URL;
return `${GEOSERVER_URL}/gwc/service/tms/1.0.0/joremapui%3A${layerName}@jore_EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`;
function getTileserverUrl(layerName: string) {
const TILESERVER_URL = constants.TILESERVER_URL;
return `${TILESERVER_URL}/jore.${layerName}/{z}/{x}/{y}.pbf`;
}

@inject('mapStore', 'networkStore', 'nodeStore', 'linkStore', 'popupStore')
Expand All @@ -52,7 +51,7 @@ class NetworkLayers extends Component<INetworkLayersProps> {

private getLinkStyle = () => {
return {
// Layer name 'linkki' is directly mirrored from Jore through geoserver
// Layer name 'linkki' is directly mirrored from Jore through tileserver
linkki: (properties: ILinkProperties) => {
const {
lnkalkusolmu: startNodeId,
Expand Down Expand Up @@ -84,7 +83,7 @@ class NetworkLayers extends Component<INetworkLayersProps> {

private getLinkPointStyle = () => {
return {
// Layer name 'piste' is directly mirrored from Jore through geoserver
// Layer name 'piste' is directly mirrored from Jore through tileserver
piste: (properties: ILinkProperties) => {
const {
lnkalkusolmu: startNodeId,
Expand Down Expand Up @@ -144,10 +143,10 @@ class NetworkLayers extends Component<INetworkLayersProps> {
};

/**
* Sets a reaction object for GeoserverLayer (replaces existing one) so
* Sets a reaction object for TileserverLayer (replaces existing one) so
* that reaction object's wouldn't multiply each time a VectorGridLayer is re-rendered.
*/
private setVectorgridLayerReaction = (type: GeoserverLayer) => (
private setVectorgridLayerReaction = (type: TileserverLayer) => (
reaction: IReactionDisposer
) => {
if (this.reactionDisposer[type]) this.reactionDisposer[type]();
Expand All @@ -165,11 +164,11 @@ class NetworkLayers extends Component<INetworkLayersProps> {
<VectorGridLayer
selectedTransitTypes={selectedTransitTypes}
selectedDate={selectedDate}
key={GeoserverLayer.Link}
key={TileserverLayer.Link}
setVectorgridLayerReaction={this.setVectorgridLayerReaction(
GeoserverLayer.Link
TileserverLayer.Link
)}
url={getGeoServerUrl(GeoserverLayer.Link)}
url={getTileserverUrl(TileserverLayer.Link)}
interactive={true}
vectorTileLayerStyles={this.getLinkStyle()}
/>
Expand All @@ -178,11 +177,11 @@ class NetworkLayers extends Component<INetworkLayersProps> {
<VectorGridLayer
selectedTransitTypes={selectedTransitTypes}
selectedDate={selectedDate}
key={GeoserverLayer.Point}
key={TileserverLayer.Point}
setVectorgridLayerReaction={this.setVectorgridLayerReaction(
GeoserverLayer.Point
TileserverLayer.Point
)}
url={getGeoServerUrl(GeoserverLayer.Point)}
url={getTileserverUrl(TileserverLayer.Point)}
interactive={false}
vectorTileLayerStyles={this.getLinkPointStyle()}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ const commonConstants = {
const developmentConstants = {
...commonConstants,
API_URL: 'http://localhost:3040',
GEOSERVER_URL: 'http://localhost:8080/geoserver',
TILESERVER_URL: 'http://localhost:7800/tiles',
FADE_ALERT_TIMEOUT: 500, // milliseconds
};

const productionConstants = {
...commonConstants,
API_URL: `${APP_URL}/api`,
GEOSERVER_URL: `${APP_URL}/geoserver`,
TILESERVER_URL: `${APP_URL}/tiles`,
FADE_ALERT_TIMEOUT: 2500, // milliseconds
};

Expand Down

0 comments on commit 9354f34

Please sign in to comment.