Skip to content

Fix dependencies issues shapely/MVT and free localost from osmose.openstreetmap.fr #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ web/po/vue.pot

web_api/session/
web_api/public/
web_api/static/
web_api/static/node_modules

web/static/.webassets-cache/
web/static/gen/
Expand Down
35 changes: 31 additions & 4 deletions osmose.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from fastapi import Depends, FastAPI, HTTPException, Request, Response, responses
from fastapi.middleware.cors import CORSMiddleware

from api import app as api
from control import app as control
Expand All @@ -10,7 +11,21 @@
from web_api import app as web_api

app = FastAPI()

assets = FastAPI()

assets.add_middleware(
CORSMiddleware,
allow_origins=[
"https://osmose.openstreetmap.fr",
"http://localhost",
"http://localhost:8080",
"http://127.0.0.1",
"http://127.0.0.1:8080",
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.on_event("startup")
async def startup():
Expand All @@ -31,6 +46,8 @@ async def startup():
app.mount("/" + lang, web_api.app)


app.mount('/assets', assets)

@app.get("/")
@app.get("/map")
@app.get("/map/")
Expand All @@ -44,7 +61,7 @@ def index(request: Request, langs: LangsNegociation = Depends(langs.langs)):
return responses.RedirectResponse(url=path)


@app.get("/assets/sprites.css")
@assets.get("/sprites.css")
def sprites_css():
file_path = "web_api/public/assets/sprites.css"
if os.path.isfile(file_path):
Expand All @@ -53,11 +70,21 @@ def sprites_css():
raise HTTPException(status_code=404)


@app.get("/assets/sprite.png")
@assets.get("/sprite.png")
def sprite_png():
return Response(open("web_api/public/assets/sprite.png", "rb").read())


@assets.get("/marker-gl-sprite.json")
def sprite_png():
return Response(open("web_api/public/assets/marker-gl-sprite.json", "rb").read())


@assets.get("/marker-gl-sprite.png")
def sprite_png():
return Response(open("web_api/public/assets/marker-gl-sprite.png", "rb").read())


@app.get("/images/markers/{filename:path}.png")
def marker(filename):
file_path = f"web_api/static/images/markers/{filename}.png"
Expand All @@ -72,4 +99,4 @@ async def catch_all(path_name: str):
if os.path.isfile(file_path):
return Response(open(file_path, "rb").read())
else:
raise HTTPException(status_code=404)
raise HTTPException(status_code=404)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ matplotlib >= 1.1
requests >= 2.0
polib
protobuf < 4 # 4.x binary not yet compatible with system package, deps of mapbox-vector-tile
shapely < 2.1.0 # cascaded_union function removal, deps of mapbox-vector-tile
mapbox-vector-tile
pyclipper
fastapi
Expand Down
4 changes: 2 additions & 2 deletions web/static/map/layers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SourceSpecification } from 'maplibre-gl'

declare var API_URL: string;

function tileSource(url, options?): SourceSpecification {
return {
type: 'raster',
Expand Down Expand Up @@ -98,8 +100,6 @@ export const mapOverlay = {
heatmap: 'Osmose Issues Heatmap',
}

const API_URL = 'https://osmose.openstreetmap.fr'

export const glStyle = {
version: 8,
sources: {
Expand Down
5 changes: 0 additions & 5 deletions web/types/index.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion web_api/static/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (env, argv) => {
},
plugins: [
new SpritezeroWebpackPlugin({
source: '../web_api/static/images/**/*.svg',
source: 'images/**/*.svg',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May you need this, because you de not run it from the right path ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run this from the docker-compose, in the osmose-frontend/docker directory

docker-compose -f docker-compose.yml -f docker-compose-test.yml up

And it didn't work unless I make the path relative to the config file (which is already in web_api/static)

output: 'marker-gl-',
})
],
Expand Down