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 diff is collapsed.
......@@ -17,13 +17,18 @@
"test:cobertura": "vitest run --coverage.enabled --reporter=junit"
},
"dependencies": {
"@ant-design/icons": "^5.2.6",
"antd": "^5.12.1",
"axios": "^1.4.0",
"date-fns": "^2.30.0",
"lodash": "^4.17.21",
"node-dijkstra": "^2.5.0",
"node-google-text-to-speech": "^0.1.0",
"react": "^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": {
"@testing-library/jest-dom": "^6.1.3",
......
......@@ -102,7 +102,7 @@ app.get('/getShortestPath', function (req, res) {
// [104.85, 2],
// [104.5,2]
// ])
console.log("Product location: ", coordinatesPath[coordinatesPath.length-1]);
res.send(coordinatesPath);
})
console.log("listening in port: 3000")
......
......@@ -6,7 +6,16 @@ import useFetch from "./hooks/useFetch";
import ProductListItem from "./components/productListItem";
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() {
const {
......@@ -48,6 +57,13 @@ function App() {
console.log("responseError: ", responseError);
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 (
<>
......
import React, { useEffect, useRef } from "react";
import React, { useEffect, useRef, useState } from "react";
import useFetch from "../../hooks/useFetch";
import { Select, Space } from "antd";
import { CloseOutlined } from "@ant-design/icons";
const shouldUpdate = (prevProps, nextProps) => {
// Custom comparison logic based on prevProps and nextProps
......@@ -7,92 +9,151 @@ const shouldUpdate = (prevProps, nextProps) => {
return !prevProps.id === nextProps.id;
};
const ProductListItem = React.memo((props: {
id: number;
title: string;
description: string;
imgLink: string;
current: number | null;
category: string;
price: number;
rating: {
rate: number;
count: number;
};
expandCallback(id: number): void;
}) => {
const currentElement = useRef(null);
const {
get,
loading: loadingImg,
error: responseError,
response: responseImg,
} = useFetch(`http://localhost:5000/`);
console.log("responseImg: ", responseImg);
const ProductListItem = React.memo(
(props: {
id: number;
title: string;
description: string;
imgLink: string;
current: number | null;
category: string;
price: number;
rating: {
rate: number;
count: number;
};
expandCallback(id: number): void;
}) => {
useEffect(()=>{
debugger
const newHeight = (props.current && props.current == props.id) ? `auto` : `8rem`;
if(currentElement.current) currentElement.current.setAttribute("style",`height:${newHeight}`);
}, [props])
const currentElement = useRef(null);
const {
get,
loading: loadingImg,
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 = () => {
get();
}
const callPythonApp = (startingPointId:string) => {
get(`startingPointId=${startingPointId}`);
};
return (
<div
id={props.id.toString()}
className={`flex tran`}
onClick={() => {
// const newHeight = (props.current && props.current == props.id) ? `auto` : `8rem`;
// if(currentElement.current) currentElement.current.setAttribute("style",`height:${newHeight}`);
props.expandCallback(props.id);
}}
ref={currentElement}
>
<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={callPythonApp} className="font-semibold text-blue-web">
Click here to get the location
</span>
{
responseImg && responseImg.image && (
<img src={`data:image/jpg;base64,${responseImg.image}`}/>
)
}
<></>
const showModal = () => {
setDisplayModal(!displayModal);
};
const handleChange = (value: string) => {
callPythonApp(value);
};
return (
<div
id={props.id.toString()}
className={`flex tran`}
onClick={() => {
// const newHeight = (props.current && props.current == props.id) ? `auto` : `8rem`;
// if(currentElement.current) currentElement.current.setAttribute("style",`height:${newHeight}`);
props.expandCallback(props.id);
}}
ref={currentElement}
>
{
displayModal && (
<div>
<div
onClick={showModal}
className="absolute top-0 left-0 w-full h-full bg-[#686868d1]"
></div>
<div className="fixed w-[80%] h-[80%] top-[10%] left-[10%] bg-white border rounded overflow-scroll">
<div className="absolute right-0 mr-3 mt-2">
<CloseOutlined onClick={showModal} />
</div>
<div className="mt-6">
<h3>Select the Starting point</h3>
<span>
Please chose the entrance or place you are more close to
</span>
</div>
<div>
<Select
defaultValue="Select the entrance"
style={{ width: 260, marginTop: "1%" }}
onChange={handleChange}
loading={loadingImg}
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>
)}
)
// 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>
);
}, shouldUpdate);
);
},
shouldUpdate
);
export default ProductListItem;
This diff is collapsed.
......@@ -81,4 +81,48 @@ A2: [102.5, 1.0],
B1A1: [100.5, 1.35],
A1: [100.5, 1.0],
SP1: [100, 1.35],
\ No newline at end of file
SP1: [100, 1.35],
// 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": [
{
"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]
]
]
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
"properties": {
"prop0": "value0",
"prop1": { "this": "that" }
}
},
{
"type": "Feature",
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"type": "LineString",
"coordinates": [
[
[100.0, 1.7],
[102.0, 1.7],
[102.0, 3.0],
[100.0, 3.0],
[100.0, 1.7]
[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
]
]
},
},
"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]
]
]
"prop1": 0.0
}
},
"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, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
{
"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]
]
}
}
]
}
\ No newline at end of file
},
"properties": {
"prop0": "value0",
"prop1": {"this": "that"}
}
}
]
}
import geopandas as gpd
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
# https://en.wikipedia.org/wiki/GeoJSON
geojson_file = "./sample.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]
]
]
}
},
geojson_file = "./floorPlan.json"
{
"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)
gdf = gpd.read_file(geojson_file)
# 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')
fig, ax = plt.subplots(figsize=(10, 10))
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
output_png = "sample-map.png"
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