Arquisoft / lomap_en3b

LoMap Software architecture group en3b course 2022_23
https://arquisoft.github.io/lomap_en3b
6 stars 0 forks source link

Render pins from pods + Filter map pins by categories. #42

Closed FdezAriasSara closed 1 year ago

FdezAriasSara commented 1 year ago
FdezAriasSara commented 1 year ago

These days I've been working on parsing the data stored in resources inside /lomap folder. Unfortunately I wasnt able to make it as I wanted, with jsonld. So I'll stick to turtle for the moment so I can advance , since trying already stopped me from advancing for the last few days. (detailed in disccusion https://github.com/Arquisoft/lomap_en3b/discussions/51#discussion-5015158

I also need to investigate a little more for including elements like comment arrays and "mixing" schema types. For the moment, we will stick to this structure, and during the spring break i will try to enhance the data stored in locations.

Example of the current status:


@prefix loc: <http://schema.org/> .

loc:Loc_1 a loc:Place ;
    loc:identifier "ResidentEvilMockPlace";
    loc:name "Racoon City" ;
    loc:description "Everybody is so weird.." ;
    loc:latitude "43.35302550278352" ;
    loc:longitude "-5.849442050492078" ;
    loc:alternateName "city" .

loc:Loc_2 a loc:Place ;
    loc:identifier "MockBeach" ;
    loc:name "Silence Beach" ;
    loc:description "Amazing place" ;
    loc:latitude "43.565795088475504" ;
    loc:longitude "-6.296431272044736" ;
    loc:alternateName "beach" .
FdezAriasSara commented 1 year ago

image Functionality of rendering pins from pods included in commit https://github.com/Arquisoft/lomap_en3b/commit/bea8b35b3337b70ab9ead27be12c1dbb0276deba?diff=split

Main things :

 //Convert into LocationLM object
           location= new LocationLM(

                Number(getStringNoLocale(locationThing, SCHEMA_INRUPT.latitude)),               // CoorLat,
               Number(getStringNoLocale(locationThing, SCHEMA_INRUPT.longitude)),              // CoorLng,
                getStringNoLocale(locationThing,SCHEMA_INRUPT.name),            // name,
                getStringNoLocale(locationThing, SCHEMA_INRUPT.description),     // description,
                getStringNoLocale(locationThing, SCHEMA_INRUPT.alternateName),   // category
            );

Latitude and longitude are strings for Inrupt's Schema vocabulary, so I parsed them as locations and then transformed them into numbers. I removed the constructor arg for id, since its generated,

Flow of execution of this functionality 1º App starts and asks the user to login 2º Once the user logs in , we check for a lomap folder 3º In case such folder is available , we display MapView component, and while doing so , all functionality of reading locations from the pod is executed For that, i pass the session object as a prop in component. In map component:

const retrieveLocations=async () => {
                  let resource = session.info.webId.replace("/profile/card#me", "/lomap/locations.ttl")
                  return await readLocations(resource, session);
              }
      in the previous snippet I call the method that makes the request and parses data into LocationLM objects
          const onMapLoad = React.useCallback((map) => {
            mapRef.current = map;
          }, []);

          React.useEffect( () => {
              async function getAndSetLocations() {
                  let locationSet = await retrieveLocations()
                  setMarkers((current) => [...current, ...locationSet]);
              }

             getAndSetLocations();
          }, []);

I use react's UseEffect to execute the code that makes the request and renders the pins.

juanmglzs commented 1 year ago

I don't understand the part that you removed the "id since it's generated". How will places (locations) and reviews be stored? How are we going to link them?

Because my first approach is generated the ID only once and keep it during the life time of the Location. So we can use it to link the reviews to a specific locación and keep track of them when loading them into the pod as a separated things (Location and Review). This can help to load them in parallel to/into the pod and when loading them in our domain model used an argumento from Review "location_referred" (this will be the location I'd) to know what location is the review related to.

I don't know if I did explain myself. If you have found a new way to do it, I'm all ears

PS: I did modified the Location class so when you create the object without is it is generated (add new location) but if you have it, it is reused (parsing from POD)

FdezAriasSara commented 1 year ago

I don't understand the part that you removed the "id since it's generated". How will places (locations) and reviews be stored? How are we going to link them?

Because my first approach is generated the ID only once and keep it during the life time of the Location. So we can use it to link the reviews to a specific locación and keep track of them when loading them into the pod as a separated things (Location and Review). This can help to load them in parallel to/into the pod and when loading them in our domain model used an argumento from Review "location_referred" (this will be the location I'd) to know what location is the review related to.

I don't know if I did explain myself. If you have found a new way to do it, I'm all ears

PS: I did modified the Location class so when you create the object without is it is generated (add new location) but if you have it, it is reused (parsing from POD)

Hi I meant i removed the argument from the constructor not the parameter itself: image we were pasing a value that is never assigned. Sorry for the confussion

btw : I don't know if this affects you that much , but in location LM image I was getting an empty array when parsing elements because in the condition, there where two !! like

if(!!value){ throw new StringInvalidFormatException(new String(str + '=' + value)); }

I changed it in my commit but well so you know in case you're working with that too

juanmglzs commented 1 year ago

Thanks

FdezAriasSara commented 1 year ago

Hi @Batuhanbyr & @RaduSeba I Just found out that the colors in the locations markers were not working because marker.type was being used instead of marker.category image

now it works as you guys intended and its soo nice, thank you ! :)

I wanted to let you know just in case you were using that attribute anywhere else these are the current attributes locations have, ( inside src/webapp/models/location.js)

image

Batuhanbyr commented 1 year ago

Thank you so much, I will be more careful. Your job is amezing thanks