Commit bb84ec81 authored by Carlos's avatar Carlos

last changes

parent b9651954
{"filename":"/Users/calvarez/Documents/Projects/Nisum/vsa-frontend/__azurite_db_blob__.json","collections":[{"name":"$SERVICES_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{},"constraints":null,"uniqueNames":["accountName"],"transforms":{},"objType":"$SERVICES_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]},{"name":"$CONTAINERS_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"accountName":{"name":"accountName","dirty":false,"values":[]},"name":{"name":"name","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$CONTAINERS_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]},{"name":"$BLOBS_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"accountName":{"name":"accountName","dirty":false,"values":[]},"containerName":{"name":"containerName","dirty":false,"values":[]},"name":{"name":"name","dirty":false,"values":[]},"snapshot":{"name":"snapshot","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$BLOBS_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]},{"name":"$BLOCKS_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"accountName":{"name":"accountName","dirty":false,"values":[]},"containerName":{"name":"containerName","dirty":false,"values":[]},"blobName":{"name":"blobName","dirty":false,"values":[]},"name":{"name":"name","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$BLOCKS_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]}],"databaseVersion":1.5,"engineVersion":1.5,"autosave":true,"autosaveInterval":5000,"autosaveHandle":null,"throttledSaves":true,"options":{"persistenceMethod":"fs","autosave":true,"autosaveInterval":5000,"serializationMethod":"normal","destructureDelimiter":"$<\n"},"persistenceMethod":"fs","persistenceAdapter":null,"verbose":false,"events":{"init":[null],"loaded":[],"flushChanges":[],"close":[],"changes":[],"warning":[]},"ENV":"NODEJS"}
\ No newline at end of file
{"filename":"/Users/calvarez/Documents/Projects/Nisum/vsa-frontend/__azurite_db_blob_extent__.json","collections":[{"name":"$EXTENTS_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"id":{"name":"id","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$EXTENTS_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]}],"databaseVersion":1.5,"engineVersion":1.5,"autosave":true,"autosaveInterval":5000,"autosaveHandle":null,"throttledSaves":true,"options":{"persistenceMethod":"fs","autosave":true,"autosaveInterval":5000,"serializationMethod":"normal","destructureDelimiter":"$<\n"},"persistenceMethod":"fs","persistenceAdapter":null,"verbose":false,"events":{"init":[null],"loaded":[],"flushChanges":[],"close":[],"changes":[],"warning":[]},"ENV":"NODEJS"}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,13 +17,18 @@ ...@@ -17,13 +17,18 @@
"test:cobertura": "vitest run --coverage.enabled --reporter=junit" "test:cobertura": "vitest run --coverage.enabled --reporter=junit"
}, },
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.2.6",
"antd": "^5.12.1",
"axios": "^1.4.0", "axios": "^1.4.0",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"node-dijkstra": "^2.5.0", "node-dijkstra": "^2.5.0",
"node-google-text-to-speech": "^0.1.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-hook-speech-to-text": "^0.8.0" "react-hook-speech-to-text": "^0.8.0",
"requirejs": "^2.3.6",
"text-to-speech-js": "^1.1.10"
}, },
"devDependencies": { "devDependencies": {
"@testing-library/jest-dom": "^6.1.3", "@testing-library/jest-dom": "^6.1.3",
......
...@@ -102,7 +102,7 @@ app.get('/getShortestPath', function (req, res) { ...@@ -102,7 +102,7 @@ app.get('/getShortestPath', function (req, res) {
// [104.85, 2], // [104.85, 2],
// [104.5,2] // [104.5,2]
// ]) // ])
console.log("Product location: ", coordinatesPath[coordinatesPath.length-1]);
res.send(coordinatesPath); res.send(coordinatesPath);
}) })
console.log("listening in port: 3000") console.log("listening in port: 3000")
......
...@@ -6,7 +6,16 @@ import useFetch from "./hooks/useFetch"; ...@@ -6,7 +6,16 @@ import useFetch from "./hooks/useFetch";
import ProductListItem from "./components/productListItem"; import ProductListItem from "./components/productListItem";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
// const tts = require("node-google-text-to-speech");
// tts.translate("en", "dog", function (result) {
// console.log(result);
// if (result.success) {
// //check for success
// const response = { audio: result.data };
// socket.emit("ttsResult", response); //emit the audio to client
// }
// });
function App() { function App() {
const { const {
...@@ -48,6 +57,13 @@ function App() { ...@@ -48,6 +57,13 @@ function App() {
console.log("responseError: ", responseError); console.log("responseError: ", responseError);
const text = results.length > 0 && results[results.length - 1].transcript; const text = results.length > 0 && results[results.length - 1].transcript;
const msg = new SpeechSynthesisUtterance();
const speak = (textToSay) => {
const msg = new SpeechSynthesisUtterance();
msg.text = textToSay;
window.speechSynthesis.speak(msg);
};
return ( return (
<> <>
......
import React, { useEffect, useRef } from "react"; import React, { useEffect, useRef, useState } from "react";
import useFetch from "../../hooks/useFetch"; import useFetch from "../../hooks/useFetch";
import { Select, Space } from "antd";
import { CloseOutlined } from "@ant-design/icons";
const shouldUpdate = (prevProps, nextProps) => { const shouldUpdate = (prevProps, nextProps) => {
// Custom comparison logic based on prevProps and nextProps // Custom comparison logic based on prevProps and nextProps
...@@ -7,92 +9,151 @@ const shouldUpdate = (prevProps, nextProps) => { ...@@ -7,92 +9,151 @@ const shouldUpdate = (prevProps, nextProps) => {
return !prevProps.id === nextProps.id; return !prevProps.id === nextProps.id;
}; };
const ProductListItem = React.memo((props: { const ProductListItem = React.memo(
id: number; (props: {
title: string; id: number;
description: string; title: string;
imgLink: string; description: string;
current: number | null; imgLink: string;
category: string; current: number | null;
price: number; category: string;
rating: { price: number;
rate: number; rating: {
count: number; rate: number;
}; count: number;
expandCallback(id: number): void; };
}) => { expandCallback(id: number): void;
const currentElement = useRef(null); }) => {
const {
get,
loading: loadingImg,
error: responseError,
response: responseImg,
} = useFetch(`http://localhost:5000/`);
console.log("responseImg: ", responseImg);
useEffect(()=>{ const currentElement = useRef(null);
debugger const {
const newHeight = (props.current && props.current == props.id) ? `auto` : `8rem`; get,
if(currentElement.current) currentElement.current.setAttribute("style",`height:${newHeight}`); loading: loadingImg,
}, [props]) error: responseError,
response: responseImg,
} = useFetch(`http://localhost:5000/`);
console.log("responseImg: ", responseImg);
const [displayModal, setDisplayModal] = useState(false);
useEffect(() => {
debugger;
const newHeight =
props.current && props.current == props.id ? `auto` : `8rem`;
if (currentElement.current)
currentElement.current.setAttribute("style", `height:${newHeight}`);
}, [props]);
const callPythonApp = () => { const callPythonApp = (startingPointId:string) => {
get(); get(`startingPointId=${startingPointId}`);
} };
return ( const showModal = () => {
<div setDisplayModal(!displayModal);
id={props.id.toString()} };
className={`flex tran`}
onClick={() => { const handleChange = (value: string) => {
// const newHeight = (props.current && props.current == props.id) ? `auto` : `8rem`; callPythonApp(value);
// if(currentElement.current) currentElement.current.setAttribute("style",`height:${newHeight}`); };
props.expandCallback(props.id);
}} return (
ref={currentElement} <div
> id={props.id.toString()}
<div className="mt-auto mb-auto ml-2 mr-2"> className={`flex tran`}
<div className="w-16"> onClick={() => {
<img src={props.imgLink}></img> // const newHeight = (props.current && props.current == props.id) ? `auto` : `8rem`;
</div> // if(currentElement.current) currentElement.current.setAttribute("style",`height:${newHeight}`);
</div> props.expandCallback(props.id);
<div className="flex flex-col p-2 pb-3"> }}
<div className="text-left font-semibold" id="header"> ref={currentElement}
<span>{props.title}</span> >
</div> {
<div id="content" className="overflow-scroll text-left text-sm"> displayModal && (
<span>{props.description}</span> <div>
{props.current && props.current == props.id && ( <div
<div className="flex flex-col"> onClick={showModal}
<div> className="absolute top-0 left-0 w-full h-full bg-[#686868d1]"
<span className="font-semibold">Category: </span>{" "} ></div>
<span>{props.category}</span>{" "} <div className="fixed w-[80%] h-[80%] top-[10%] left-[10%] bg-white border rounded overflow-scroll">
</div> <div className="absolute right-0 mr-3 mt-2">
<div> <CloseOutlined onClick={showModal} />
<span className="font-semibold">Price: </span>{" "} </div>
<span>{props.price}</span> <div className="mt-6">
</div> <h3>Select the Starting point</h3>
<div> <span>
<span className="font-semibold">Rating: </span>{" "} Please chose the entrance or place you are more close to
<span>{props.rating.rate}</span> </span>
</div> </div>
<div> <div>
<span onClick={callPythonApp} className="font-semibold text-blue-web"> <Select
Click here to get the location defaultValue="Select the entrance"
</span> style={{ width: 260, marginTop: "1%" }}
{ onChange={handleChange}
responseImg && responseImg.image && ( loading={loadingImg}
<img src={`data:image/jpg;base64,${responseImg.image}`}/> options={[
) { value: "SP1", label: "ENTRANCE 1" },
} { value: "SP2", label: "ENTRANCE 2" },
<></> { value: "SP3", label: "ENTRANCE 3" },
{ value: "SP4", label: "ENTRANCE 4" },
{ value: "SP5", label: "ENTRANCE 5" },
{ value: "SP6", label: "ENTRANCE 6" },
]}
/>
{responseImg && responseImg.image && (
<img
className="max-w-screen-md ml-auto mr-auto mt-8 w-full"
src={`data:image/jpg;base64,${responseImg.image}`}
/>
)}
</div>
</div> </div>
</div> </div>
)} )
// responseImg && responseImg.image && (
// <img src={`data:image/jpg;base64,${responseImg.image}`}/>
// )
}
<div className="mt-auto mb-auto ml-2 mr-2">
<div className="w-16">
<img src={props.imgLink}></img>
</div>
</div>
<div className="flex flex-col p-2 pb-3">
<div className="text-left font-semibold" id="header">
<span>{props.title}</span>
</div>
<div id="content" className="overflow-scroll text-left text-sm">
<span>{props.description}</span>
{props.current && props.current == props.id && (
<div className="flex flex-col">
<div>
<span className="font-semibold">Category: </span>{" "}
<span>{props.category}</span>{" "}
</div>
<div>
<span className="font-semibold">Price: </span>{" "}
<span>{props.price}</span>
</div>
<div>
<span className="font-semibold">Rating: </span>{" "}
<span>{props.rating.rate}</span>
</div>
<div>
<span
onClick={showModal}
className="font-semibold text-blue-web"
>
Click here to get the location
</span>
<></>
</div>
</div>
)}
</div>
</div> </div>
</div> </div>
</div> );
); },
}, shouldUpdate); shouldUpdate
);
export default ProductListItem; export default ProductListItem;
from flask import Flask, jsonify from flask import Flask, jsonify, request
import geopandas as gpd import geopandas as gpd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib import matplotlib
from flask_cors import CORS from flask_cors import CORS
import matplotlib.font_manager as fm
import requests import requests
from io import BytesIO from io import BytesIO
import base64 import base64
# to start the server please run: python -m flask run
matplotlib.use('Agg') matplotlib.use('Agg')
title_font = fm.FontProperties(family='Arial', style='normal', size=10, weight='normal', stretch='normal')
app = Flask(__name__) app = Flask(__name__)
CORS(app) CORS(app)
def generate_image(gdf): def generate_image(gdf):
fig, ax = plt.subplots(figsize=(10, 10)) fig, ax = plt.subplots(figsize=(10, 10))
# gdf['coords'] = gdf['geometry'].apply(lambda x: x.representative_point().coords[:])
# gdf['coords'] = [coords[0] for coords in gdf['coords']]
gdf.plot(ax=ax) gdf.plot(ax=ax)
#for idx, row in gdf.iterrows():
# plt.annotate(s=row['prop0'], xy=row['coords'], horizontalalignment='center')
ax.set_title('Store floor plan', fontproperties=title_font)
gdf.apply(lambda x:
ax.annotate(text=x['prop0'],
xy=(x.geometry.centroid.x, x.geometry.centroid.y+0.1),
ha='center')
if x['type']=='gate' else
ax.annotate(text=x['prop0'],
xy=(x.geometry.centroid.x, x.geometry.centroid.y),
bbox=dict(boxstyle='round', color='k', fc='w', alpha=0.8),
ha='center'),
axis=1)
# Save the plot to a BytesIO object # Save the plot to a BytesIO object
image_stream = BytesIO() image_stream = BytesIO()
plt.savefig(image_stream, format='png', dpi=300, bbox_inches='tight') plt.savefig(image_stream, format='png', dpi=300, bbox_inches='tight')
...@@ -27,287 +52,348 @@ def generate_image(gdf): ...@@ -27,287 +52,348 @@ def generate_image(gdf):
@app.route("/") @app.route("/")
def hello_world(): def hello_world():
print('hee') print('hee')
startingPointId = request.args.get('startingPointId')
print("From: "+startingPointId)
# pre Step: getting the path lineString coordinates # pre Step: getting the path lineString coordinates
api_url = "http://localhost:3000/getShortestPath?productLocationId=SP5&startingPointId=A1" api_url = "http://localhost:3000/getShortestPath?productLocationId=A1&startingPointId="+startingPointId
response = requests.get(api_url) response = requests.get(api_url)
coordinates = response.json() coordinates = response.json()
print(str(coordinates)) print(str(coordinates[-1]))
# Step 1: Read the GeoJSON file using GeoPandas # Step 1: Read the GeoJSON file using GeoPandas
# https://en.wikipedia.org/wiki/GeoJSON # https://en.wikipedia.org/wiki/GeoJSON
geojson_file = "./sample.json"
geojson_str = ''' geojson_str = '''
{ {
"type": "FeatureCollection", "type": "FeatureCollection",
"features": [ "features": [
{ {
"type": "Feature", "type": "Feature",
"geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "geometry": {
"properties": { "prop0": "value0" } "type": "Polygon",
}, "coordinates": [
{ [
"type": "Feature", [100.0, 0.0],
"geometry": { [101.0, 0.0],
"type": "Polygon", [101.0, 1.0],
"coordinates": [ [100.0, 1.0],
[ [100.0, 0.0]
[101.1, 0.0], ]
[104.0, 0.0], ]
[104.0, 1.0], },
[101.1, 1.0], "properties": {
[101.1, 0.0] "prop0": "A1",
] "prop1": { "this": "that" },
] "type": "section"
}, }
"properties": { },
"prop0": "value0", {
"prop1": { "this": "that" } "type": "Feature",
} "geometry": {
}, "type": "Polygon",
{ "coordinates": [
"type": "Feature", [
"geometry": { [101.1, 0.0],
"type": "Polygon", [104.0, 0.0],
"coordinates": [ [104.0, 1.0],
[ [101.1, 1.0],
[104.1, 0.0], [101.1, 0.0]
[107.0, 0.0], ]
[107.0, 1.0], ]
[104.1, 1.0], },
[104.1, 0.0] "properties": {
] "prop0": "A2",
] "prop1": { "this": "that" },
}, "type": "section"
"properties": { }
"prop0": "value0", },
"prop1": { "this": "that" } {
} "type": "Feature",
}, "geometry": {
{ "type": "Polygon",
"type": "Feature", "coordinates": [
"geometry": { [
"type": "Polygon", [104.1, 0.0],
"coordinates": [ [107.0, 0.0],
[ [107.0, 1.0],
[100.0, 0.0], [104.1, 1.0],
[101.0, 0.0], [104.1, 0.0]
[101.0, 1.0], ]
[100.0, 1.0], ]
[100.0, 0.0] },
] "properties": {
] "prop0": "A3",
}, "prop1": { "this": "that" },
"properties": { "type": "section"
"prop0": "value0", }
"prop1": { "this": "that" } },
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 1.7],
[102.0, 1.7],
[102.0, 3.0],
[100.0, 3.0],
[100.0, 1.7]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 1.7],
[103.1, 1.7],
[103.1, 3.0],
[102.1, 3.0],
[102.1, 1.7]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 2.4],
[104.5, 2.4],
[104.5, 3.0],
[103.2, 3.0],
[103.2, 2.4]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 1.7],
[104.5, 1.7],
[104.5, 2.3],
[103.2, 2.3],
[103.2, 1.7]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 1.7],
[107.0, 1.7],
[107.0, 3.0],
[105.2, 3.0],
[105.2, 1.7]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 1.7],
[102.0, 1.7],
[102.0, 3.0],
[100.0, 3.0],
[100.0, 1.7]
]
]
},
"properties": {
"prop0": "B1",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 1.7],
[103.1, 1.7],
[103.1, 3.0],
[102.1, 3.0],
[102.1, 1.7]
]
]
},
"properties": {
"prop0": "B2",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 2.4],
[104.5, 2.4],
[104.5, 3.0],
[103.2, 3.0],
[103.2, 2.4]
]
]
},
"properties": {
"prop0": "B3",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 1.7],
[104.5, 1.7],
[104.5, 2.3],
[103.2, 2.3],
[103.2, 1.7]
]
]
},
"properties": {
"prop0": "B4",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 1.7],
[107.0, 1.7],
[107.0, 3.0],
[105.2, 3.0],
[105.2, 1.7]
]
]
},
"properties": {
"prop0": "B5",
"prop1": { "this": "that" },
"type": "section"
}
},
{ {
"type": "Feature", "type": "Feature",
"geometry": { "geometry": {
"type": "Polygon", "type": "Polygon",
"coordinates": [ "coordinates": [
[ [
[100.0, 3.6], [100.0, 3.6],
[101.4, 3.6], [101.4, 3.6],
[101.4, 4.9], [101.4, 4.9],
[100.0, 4.9], [100.0, 4.9],
[100.0, 3.6] [100.0, 3.6]
] ]
] ]
}, },
"properties": { "properties": {
"prop0": "value0", "prop0": "C1",
"prop1": { "this": "that" } "prop1": { "this": "that" },
} "type": "section"
}, }
{ },
"type": "Feature", {
"geometry": { "type": "Feature",
"type": "Polygon", "geometry": {
"coordinates": [ "type": "Polygon",
[ "coordinates": [
[102.1, 3.6], [
[103.1, 3.6], [102.1, 3.6],
[103.1, 4.9], [103.1, 3.6],
[102.1, 4.9], [103.1, 4.9],
[102.1, 3.6] [102.1, 4.9],
] [102.1, 3.6]
] ]
}, ]
"properties": { },
"prop0": "value0", "properties": {
"prop1": { "this": "that" } "prop0": "C2",
} "prop1": { "this": "that" },
}, "type": "section"
{ }
"type": "Feature", },
"geometry": { {
"type": "Polygon", "type": "Feature",
"coordinates": [ "geometry": {
[ "type": "Polygon",
[103.2, 3.6], "coordinates": [
[104.5, 3.6], [
[104.5, 4.9], [103.2, 3.6],
[103.2, 4.9], [104.5, 3.6],
[103.2, 3.6] [104.5, 4.9],
] [103.2, 4.9],
] [103.2, 3.6]
} ]
}, ]
{ },
"type": "Feature", "properties": {
"geometry": { "prop0": "C3",
"type": "Polygon", "prop1": { "this": "that" },
"coordinates": [ "type": "section"
[ }
[105.2, 3.6], },
[107.0, 3.6], {
[107.0, 4.9], "type": "Feature",
[105.2, 4.9], "geometry": {
[105.2, 3.6] "type": "Polygon",
] "coordinates": [
] [
} [105.2, 3.6],
}, [107.0, 3.6],
{ [107.0, 4.9],
"type": "Feature", [105.2, 4.9],
"geometry": { [105.2, 3.6]
"type": "MultiPoint", ]
"coordinates": [ ]
[101.75, 5], },
[101.75, 4.3], "properties": {
[101.4, 4.3], "prop0": "C4",
[100.5, 3.3], "prop1": { "this": "that" },
[100.5, 3.0], "type": "section"
[100, 3.3], }
[101.75, 3.3], },
[104.85, 3.3], {
[102.7, 3.3], "type": "Feature",
[102.7, 3.6], "geometry": {
[102.7, 3.0], "type": "Point",
[103.7, 3.3], "coordinates": [100, 1.35]
[103.7, 3.6], },
[103.7, 3.0], "properties": {
[106.2, 3.3], "prop0": "GATE 1",
[107, 3.3], "prop1": { "this": "that" },
[106.2, 3.0], "type": "gate"
[104.85, 4.3], }
[105.2, 4.3], },{
[104.85, 5], "type": "Feature",
[104.85, 2], "geometry": {
[104.50, 2], "type": "Point",
[104.85, 1.35], "coordinates": [107, 1.35]
[105.5, 1.35], },
[105.5, 1.0], "properties": {
[107, 1.35], "prop0": "GATE 2",
[102.5, 1.35], "prop1": { "this": "that" },
[102.5, 1.0], "type": "gate"
[100.5, 1.35], }
[100.5, 1.0], },{
[100, 1.35] "type": "Feature",
] "geometry": {
} "type": "Point",
},'''+''' { "coordinates": [107, 3.3]
},
"properties": {
"prop0": "GATE 3",
"prop1": { "this": "that" },
"type": "gate"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [104.85, 5]
},
"properties": {
"prop0": "GATE 4",
"prop1": { "this": "that" },
"type": "gate"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [101.75, 5]
},
"properties": {
"prop0": "GATE 5",
"prop1": { "this": "that" },
"type": "gate"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [100, 3.3]
},
"properties": {
"prop0": "GATE 6",
"prop1": { "this": "that" },
"type": "gate"
}
},'''+''' {
"type": "Feature", "type": "Feature",
"geometry": { "geometry": {
"type": "LineString", "type": "LineString",
"coordinates": "coordinates":
'''+str(coordinates)+''' '''+str(coordinates)+'''
} }
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates":
'''+str(coordinates[-1])+'''
} }
'''+''' }
] ]
}''' }'''
......
...@@ -81,4 +81,48 @@ A2: [102.5, 1.0], ...@@ -81,4 +81,48 @@ A2: [102.5, 1.0],
B1A1: [100.5, 1.35], B1A1: [100.5, 1.35],
A1: [100.5, 1.0], A1: [100.5, 1.0],
SP1: [100, 1.35], SP1: [100, 1.35],
\ No newline at end of file
// all points
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[101.75, 5],
[101.75, 4.3],
[101.4, 4.3],
[100.5, 3.3],
[100.5, 3.0],
[101.75, 3.3],
[104.85, 3.3],
[102.7, 3.3],
[102.7, 3.6],
[102.7, 3.0],
[103.7, 3.3],
[103.7, 3.6],
[103.7, 3.0],
[106.2, 3.3],
[107, 3.3],
[106.2, 3.0],
[104.85, 4.3],
[105.2, 4.3],
[104.85, 5],
[104.85, 2],
[104.5, 2],
[104.85, 1.35],
[105.5, 1.35],
[105.5, 1.0],
[107, 1.35],
[102.5, 1.35],
[102.5, 1.0],
[100.5, 1.35],
[100.5, 1.0],
[100, 1.35]
]
}
},
\ No newline at end of file
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
},
"properties": {
"prop0": "A1",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[101.1, 0.0],
[104.0, 0.0],
[104.0, 1.0],
[101.1, 1.0],
[101.1, 0.0]
]
]
},
"properties": {
"prop0": "A2",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[104.1, 0.0],
[107.0, 0.0],
[107.0, 1.0],
[104.1, 1.0],
[104.1, 0.0]
]
]
},
"properties": {
"prop0": "A3",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 1.7],
[102.0, 1.7],
[102.0, 3.0],
[100.0, 3.0],
[100.0, 1.7]
]
]
},
"properties": {
"prop0": "B1",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 1.7],
[103.1, 1.7],
[103.1, 3.0],
[102.1, 3.0],
[102.1, 1.7]
]
]
},
"properties": {
"prop0": "B2",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 2.4],
[104.5, 2.4],
[104.5, 3.0],
[103.2, 3.0],
[103.2, 2.4]
]
]
},
"properties": {
"prop0": "B3",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 1.7],
[104.5, 1.7],
[104.5, 2.3],
[103.2, 2.3],
[103.2, 1.7]
]
]
},
"properties": {
"prop0": "B4",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 1.7],
[107.0, 1.7],
[107.0, 3.0],
[105.2, 3.0],
[105.2, 1.7]
]
]
},
"properties": {
"prop0": "B5",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 3.6],
[101.4, 3.6],
[101.4, 4.9],
[100.0, 4.9],
[100.0, 3.6]
]
]
},
"properties": {
"prop0": "C1",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 3.6],
[103.1, 3.6],
[103.1, 4.9],
[102.1, 4.9],
[102.1, 3.6]
]
]
},
"properties": {
"prop0": "C2",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 3.6],
[104.5, 3.6],
[104.5, 4.9],
[103.2, 4.9],
[103.2, 3.6]
]
]
},
"properties": {
"prop0": "C3",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 3.6],
[107.0, 3.6],
[107.0, 4.9],
[105.2, 4.9],
[105.2, 3.6]
]
]
},
"properties": {
"prop0": "C4",
"prop1": { "this": "that" },
"type": "section"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [100, 1.35]
},
"properties": {
"prop0": "GATE 1",
"prop1": { "this": "that" },
"type": "gate"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [107, 1.35]
},
"properties": {
"prop0": "GATE 2",
"prop1": { "this": "that" },
"type": "gate"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [107, 3.3]
},
"properties": {
"prop0": "GATE 3",
"prop1": { "this": "that" },
"type": "gate"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [104.85, 5]
},
"properties": {
"prop0": "GATE 4",
"prop1": { "this": "that" },
"type": "gate"
}
},{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [101.75, 5]
},
"properties": {
"prop0": "GATE 5",
"prop1": { "this": "that" },
"type": "gate"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [100, 3.3]
},
"properties": {
"prop0": "GATE 6",
"prop1": { "this": "that" },
"type": "gate"
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[100, 1.35],
[104.85, 1.35],
[104.85, 2],
[104.5, 2]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [104.5, 2]
}
}
]
}
utils-resources/sample-map.png

41.6 KB | W: | H:

utils-resources/sample-map.png

92 KB | W: | H:

utils-resources/sample-map.png
utils-resources/sample-map.png
utils-resources/sample-map.png
utils-resources/sample-map.png
  • 2-up
  • Swipe
  • Onion skin
{ { "type": "FeatureCollection",
"type": "FeatureCollection",
"features": [ "features": [
{ { "type": "Feature",
"type": "Feature", "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": {"prop0": "value0"}
"properties": { "prop0": "value0" }
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[101.1, 0.0],
[104.0, 0.0],
[104.0, 1.0],
[101.1, 1.0],
[101.1, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[104.1, 0.0],
[107.0, 0.0],
[107.0, 1.0],
[104.1, 1.0],
[104.1, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
}, },
"properties": { { "type": "Feature",
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": { "geometry": {
"type": "Polygon", "type": "LineString",
"coordinates": [ "coordinates": [
[ [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
[100.0, 1.7],
[102.0, 1.7],
[102.0, 3.0],
[100.0, 3.0],
[100.0, 1.7]
] ]
] },
},
"properties": { "properties": {
"prop0": "value0", "prop0": "value0",
"prop1": { "this": "that" } "prop1": 0.0
} }
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 1.7],
[103.1, 1.7],
[103.1, 3.0],
[102.1, 3.0],
[102.1, 1.7]
]
]
}, },
"properties": { { "type": "Feature",
"prop0": "value0", "geometry": {
"prop1": { "this": "that" } "type": "Polygon",
} "coordinates": [
}, [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
{ [100.0, 1.0], [100.0, 0.0] ]
"type": "Feature", ]
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 2.4],
[104.5, 2.4],
[104.5, 3.0],
[103.2, 3.0],
[103.2, 2.4]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 1.7],
[104.5, 1.7],
[104.5, 2.3],
[103.2, 2.3],
[103.2, 1.7]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 1.7],
[107.0, 1.7],
[107.0, 3.0],
[105.2, 3.0],
[105.2, 1.7]
]
]
}
},
},
"properties": {
{ "prop0": "value0",
"type": "Feature", "prop1": {"this": "that"}
"geometry": { }
"type": "Polygon", }
"coordinates": [ ]
[ }
[100.0, 3.6],
[101.4, 3.6],
[101.4, 4.9],
[100.0, 4.9],
[100.0, 3.6]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 3.6],
[103.1, 3.6],
[103.1, 4.9],
[102.1, 4.9],
[102.1, 3.6]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 3.6],
[104.5, 3.6],
[104.5, 4.9],
[103.2, 4.9],
[103.2, 3.6]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 3.6],
[107.0, 3.6],
[107.0, 4.9],
[105.2, 4.9],
[105.2, 3.6]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[101.75, 5],
[101.75, 4.3],
[101.4, 4.3],
[100.5, 3.3],
[100.5, 3.0],
[100, 3.3],
[101.75, 3.3],
[104.85, 3.3],
[102.7, 3.3],
[102.7, 3.6],
[102.7, 3.0],
[103.7, 3.3],
[103.7, 3.6],
[103.7, 3.0],
[106.2, 3.3],
[107, 3.3],
[106.2, 3.0],
[104.85, 4.3],
[105.2, 4.3],
[104.85, 5],
[104.85, 2],
[104.50, 2],
[104.85, 1.35],
[105.5, 1.35],
[105.5, 1.0],
[107, 1.35],
[102.5, 1.35],
[102.5, 1.0],
[100.5, 1.35],
[100.5, 1.0],
[100, 1.35]
]
}
}
]
}
\ No newline at end of file
import geopandas as gpd import geopandas as gpd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
title_font = fm.FontProperties(family='Arial', style='normal', size=12, weight='normal', stretch='normal')
# pre Step: getting the path lineString coordinates
import requests
api_url = "http://localhost:3000/getGuidedImage?productCoordinates=[104.5,%202]&startingPointCoordinates=[100,%201.35]"
response = requests.get(api_url)
coordinates = response.json()
print(str(coordinates))
# Step 1: Read the GeoJSON file using GeoPandas # Step 1: Read the GeoJSON file using GeoPandas
# https://en.wikipedia.org/wiki/GeoJSON # https://en.wikipedia.org/wiki/GeoJSON
geojson_file = "./sample.json" geojson_file = "./floorPlan.json"
geojson_str = '''
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [102.0, 0.5] },
"properties": { "prop0": "value0" }
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[101.1, 0.0],
[104.0, 0.0],
[104.0, 1.0],
[101.1, 1.0],
[101.1, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[104.1, 0.0],
[107.0, 0.0],
[107.0, 1.0],
[104.1, 1.0],
[104.1, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 1.7],
[102.0, 1.7],
[102.0, 3.0],
[100.0, 3.0],
[100.0, 1.7]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 1.7],
[103.1, 1.7],
[103.1, 3.0],
[102.1, 3.0],
[102.1, 1.7]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 2.4],
[104.5, 2.4],
[104.5, 3.0],
[103.2, 3.0],
[103.2, 2.4]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 1.7],
[104.5, 1.7],
[104.5, 2.3],
[103.2, 2.3],
[103.2, 1.7]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 1.7],
[107.0, 1.7],
[107.0, 3.0],
[105.2, 3.0],
[105.2, 1.7]
]
]
}
},
{ gdf = gpd.read_file(geojson_file)
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 3.6],
[101.4, 3.6],
[101.4, 4.9],
[100.0, 4.9],
[100.0, 3.6]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[102.1, 3.6],
[103.1, 3.6],
[103.1, 4.9],
[102.1, 4.9],
[102.1, 3.6]
]
]
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[103.2, 3.6],
[104.5, 3.6],
[104.5, 4.9],
[103.2, 4.9],
[103.2, 3.6]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[105.2, 3.6],
[107.0, 3.6],
[107.0, 4.9],
[105.2, 4.9],
[105.2, 3.6]
]
]
}
},
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[101.75, 5],
[101.75, 4.3],
[101.4, 4.3],
[100.5, 3.3],
[100.5, 3.0],
[100, 3.3],
[101.75, 3.3],
[104.85, 3.3],
[102.7, 3.3],
[102.7, 3.6],
[102.7, 3.0],
[103.7, 3.3],
[103.7, 3.6],
[103.7, 3.0],
[106.2, 3.3],
[107, 3.3],
[106.2, 3.0],
[104.85, 4.3],
[105.2, 4.3],
[104.85, 5],
[104.85, 2],
[104.50, 2],
[104.85, 1.35],
[105.5, 1.35],
[105.5, 1.0],
[107, 1.35],
[102.5, 1.35],
[102.5, 1.0],
[100.5, 1.35],
[100.5, 1.0],
[100, 1.35]
]
}
},'''+''' {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates":
'''+str(coordinates)+'''
}
}
'''+'''
]
}'''
gdf = gpd.read_file(geojson_str, driver='GeoJSON')
# gdf = gpd.read_file(geojson_file)
# How to place the geometrycs in a non empty png with the plan/map of the store. # How to place the geometrycs in a non empty png with the plan/map of the store.
...@@ -296,6 +16,20 @@ gdf = gpd.read_file(geojson_str, driver='GeoJSON') ...@@ -296,6 +16,20 @@ gdf = gpd.read_file(geojson_str, driver='GeoJSON')
fig, ax = plt.subplots(figsize=(10, 10)) fig, ax = plt.subplots(figsize=(10, 10))
gdf.plot(ax=ax) gdf.plot(ax=ax)
ax.set_title('Store floor map', fontproperties=title_font)
gdf.apply(lambda x:
ax.annotate(text=x['prop0'],
xy=(x.geometry.centroid.x, x.geometry.centroid.y+0.1),
ha='center')
if x['type']=='gate' else
ax.annotate(text=x['prop0'],
xy=(x.geometry.centroid.x, x.geometry.centroid.y),
bbox=dict(boxstyle='round', color='k', fc='w', alpha=0.8),
ha='center'),
axis=1)
# Step 3: Save the plot as a PNG file # Step 3: Save the plot as a PNG file
output_png = "sample-map.png" output_png = "sample-map.png"
plt.savefig(output_png, dpi=300, bbox_inches='tight') plt.savefig(output_png, dpi=300, bbox_inches='tight')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment