Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Aug 14, 2023
1 parent 71c21bd commit 9dd9b68
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 41 deletions.
31 changes: 7 additions & 24 deletions src/js/edgesolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import 'toastify-js/src/toastify.css'

let orderedEdges = []

export function clearEdges() {
export function clearEdges () {
orderedEdges = []
// clear all previous features so only the last drawn feature remains
resultsLayer.getSource().clear()
}

function resultsStyle(feature, resolution) {
function resultsStyle (feature, resolution) {
let text

if (feature.getGeometry().getType() === 'LineString') {
Expand Down Expand Up @@ -73,7 +73,7 @@ const resultsLayer = new VectorLayer({
style: resultsStyle
})

function clearPreviousFeatures() {
function clearPreviousFeatures () {
// remove any previous edges from the results layer

resultsLayer.getSource().forEachFeature(function (feature) {
Expand All @@ -98,8 +98,7 @@ function clearPreviousFeatures() {
// })
// }


function isFeatureSnapped(map, coord, searchLayer) {
function isFeatureSnapped (map, coord, searchLayer) {
let extent = boundingExtent([coord]) // still a single point
const bufferDistance = map.getView().getResolution() * 3 // use a 6 pixel tolerance for snapping
extent = buffer(extent, bufferDistance) // buffer the point
Expand All @@ -113,8 +112,7 @@ function isFeatureSnapped(map, coord, searchLayer) {
}
}


function serviceCallback(data) {
function serviceCallback (data) {
// load route from the GeoJSON

clearPreviousFeatures()
Expand All @@ -125,10 +123,9 @@ function serviceCallback(data) {
resultsLayer.getSource().addFeatures(feats)

// highlightRoute(networkLayer, resultsLayer, data)dateTable(feats, selectInteraction, resultsLayer)

}

function drawEnd(evt, networkLayer, resultsLayer) {
function drawEnd (evt, networkLayer, resultsLayer) {
const feature = evt.feature
const coordinate = feature.getGeometry().getCoordinates()
const closestNetworkFeature = networkLayer.getSource().getClosestFeatureToCoordinate(coordinate)
Expand All @@ -148,21 +145,7 @@ function drawEnd(evt, networkLayer, resultsLayer) {
}
}

function showToast(text) {
Toastify({
text,
duration: 3000,
close: true,
gravity: 'bottom', // `top` or `bottom`
position: 'right', // `left`, `center` or `right`
stopOnFocus: true // Prevents dismissing of toast on hover
// style: {
// background: "linear-gradient(to right, #00b09b, #96c93d)",
// },
}).showToast()
}

export function createEdgeSolver(map, networkLayer) {
export function createEdgeSolver (map, networkLayer) {
map.addLayer(resultsLayer)

const draw = new Draw({
Expand Down
2 changes: 1 addition & 1 deletion src/js/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/css/bootstrap.min.css'
4 changes: 2 additions & 2 deletions src/js/isochrones.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { createIsochroneTool } from './isochronessolver.js'

import { createNetworkLayer, toggleLabels } from './networklayer.js'

function init() {
function init () {
const geojsonFile = './data/stbrice.json'
const extent = [2.3314107610246633, 48.988440397479536, 2.4050093789098863, 49.01280894618151]
const bbox = transformExtent(extent, 'EPSG:4326', 'EPSG:3857')
const background = null// '#1a2b39' //null
const showOSM = true
// const showOSM = true

const networkLayer = createNetworkLayer(geojsonFile, background)

Expand Down
8 changes: 3 additions & 5 deletions src/js/networklayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Point } from 'ol/geom'
let showNetworkLabels = false
let networkLayer

let networkLineColor = 'rgba(255, 255, 255, 0.7)';
let networkLineColor = 'rgba(255, 255, 255, 0.7)'

function networkStyle (feature, resolution) {
function getText (feature) {
Expand All @@ -20,7 +20,7 @@ function networkStyle (feature, resolution) {

const styles = [new Style({
stroke: new Stroke({
color: networkLineColor, //'rgba(255, 255, 255, 0.7)',
color: networkLineColor, // 'rgba(255, 255, 255, 0.7)',
width: 2
}),
text: new Text({
Expand Down Expand Up @@ -49,7 +49,6 @@ function networkStyle (feature, resolution) {
const dy = end[1] - start[1]
const rotation = Math.atan2(dy, dx)


styles.push(
new Style({
geometry: new Point(centerCoordinate),
Expand Down Expand Up @@ -103,8 +102,7 @@ export function toggleLabels () {
networkLayer.getSource().changed()
}

export function createNetworkLayer(jsn, background = '#1a2b39', lineColor = 'rgba(255, 255, 255, 0.7)') {

export function createNetworkLayer (jsn, background = '#1a2b39', lineColor = 'rgba(255, 255, 255, 0.7)') {
networkLineColor = lineColor

networkLayer = new VectorLayer({
Expand Down
4 changes: 2 additions & 2 deletions src/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export function updateTable (feats, originSelectInteraction, originResultsLayer)

// myTable.refresh()

const tableDiv = document.getElementById('mydiv');
tableDiv.style.visibility = 'visible';
const tableDiv = document.getElementById('mydiv')
tableDiv.style.visibility = 'visible'
}

export function createTable () {
Expand Down
14 changes: 7 additions & 7 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export default {
hot: true,
proxy: {
// note the Python services must also be deployed to an /api end point
"/api": {
target: "http://127.0.0.1:8020",
'/api': {
target: 'http://127.0.0.1:8020',
changeOrigin: true,
secure: false,
},
},
secure: false
}
}
},
build: {
sourcemap: true,
Expand All @@ -35,7 +35,7 @@ export default {
hook: 'writeBundle'
})
]
},
}

},
}
}

0 comments on commit 9dd9b68

Please sign in to comment.