Skip to content

Commit

Permalink
Code update on 18.10.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
g-nardiello committed Oct 18, 2024
1 parent 39fb2bd commit 6b33cb3
Show file tree
Hide file tree
Showing 13 changed files with 799 additions and 280 deletions.
2 changes: 1 addition & 1 deletion app/components/featureInfoPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const FeatureInfoPopup: React.FC<FeatureInfoPopupProps> = ({ map, checkedLayerLi
const url = source.getFeatureInfoUrl(
coordinate,
viewResolution,
'EPSG:3857',
'EPSG:2056',
{ 'INFO_FORMAT': 'text/xml' }
);
if (!url) return;
Expand Down
19 changes: 12 additions & 7 deletions app/components/openLayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ import { createExpansLayersList, getFeaturesLayers, getSourceById } from '../uti
import { createQueryString } from '../utilities/StringCreateFilter';
import FeatureInfoPopup from './featureInfoPopup';
import { setAttributesConfiguration } from '../slice/layerMenuSlice';
import proj4 from 'proj4';
import { register } from 'ol/proj/proj4.js';


proj4.defs("EPSG:2056", "+proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs +type=crs");
register(proj4);

/**
* The map that contains layer ids and tileLayer
*/
Expand Down Expand Up @@ -81,6 +86,7 @@ const MapComponent: React.FC = () => {
*/
const featuredFilterableLayers = expandedLayerListFiltered.filter(layer => layer.canGetFeatureInfo);
const dispatch = useDispatch();
const defaultExtend = [2479999.9701, 1061999.6351, 2865002.5601, 1302018.7201];
/**
* Creates the expanded list of layers by setting the layerTilesMap.
*
Expand All @@ -105,6 +111,7 @@ const MapComponent: React.FC = () => {
tileLayer.setZIndex(layer.zIndex);
}
tileLayers[layer.id] = tileLayer;
console.log(tileLayer);
}
}
});
Expand Down Expand Up @@ -172,10 +179,11 @@ const MapComponent: React.FC = () => {
layers: [],
view: new View({
//in order: longitude, latitude
center: [915788.3813658266, 5909670.533831278],
center: [2660013.54, 1185171.98],
zoom: 8.6,
minZoom: 0,
maxZoom: 28,
projection: 'EPSG:2056'
}),
controls: defaults({ attribution: false }).extend([
new Attribution({
Expand All @@ -186,15 +194,12 @@ const MapComponent: React.FC = () => {
new ScaleLine(),
new ZoomToExtent({
label: 'D',
extent: new View({
center: [915788.3813658266, 5909670.533831278],
zoom: 5,
}).getViewStateAndExtent().extent
extent: defaultExtend,
}),
new Rotate(),
]),
});

newMap.getView().fit(defaultExtend);
setMap(newMap);

const layersToAdd = checkedLayers.filter(layer => {
Expand Down Expand Up @@ -336,7 +341,7 @@ const MapComponent: React.FC = () => {
const url = source.getFeatureInfoUrl(
center,
viewResolution,
'EPSG:3857',
'EPSG:2056',
{ 'INFO_FORMAT': 'text/xml' }
);
if (!url) return;
Expand Down
729 changes: 512 additions & 217 deletions app/components/queryTools.tsx

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions app/css/styleQueryTools.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
height: 100vh;
min-width: 300px;
padding: 20px;
overflow-y: auto;
}

.bgGrey {
Expand All @@ -15,6 +16,9 @@
.textBlack {
color: black;
}
.mTop2 {
margin-top: 2%;
}

.mTop4 {
margin-top: 4%;
Expand Down
10 changes: 10 additions & 0 deletions app/enum/filterTypeEnum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@
export enum FiltersType {
FilterByAttribute = 'filterByAttribute', //Identifies a filter type based on attributes.
FilterByTectoUnitsTerm = 'filterByTectoUnitsTerm', //Identifies a filter type based on tectonic units terms.
FilterByChronostratigraphy= 'filterByChronostratigraphy', //Identifies a filter type based on chronostratigraphy terms.
}

/**
* This enum is used to specify the type of filter Chronostratigraphy.
*/
export enum FilterOptionChronostratigraphy {
Younger = "yon",
Between = "bet",
Older = "old",
}
3 changes: 2 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const encodeSansExpanded = Encode_Sans_Expanded({

export const metadata: Metadata = {
title: "WebMap - Swissgeol",
description: "Generated by NARDS IT",
description: "Developed by Nards IT",
authors: [{name:"Nards IT", url: "https://nards.it"}]
};

export default function RootLayout({
Expand Down
27 changes: 10 additions & 17 deletions app/libs/graphDbWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ interface Literal {
value: string;
language?: string;
}
interface QueryResult {
interface VocabularyQueryResult {
term: NamedNode;
prefLabel: Literal;
}
interface QueryResultNarrowers {
narrowerConcept: NamedNode;
interface ConceptQueryResult {
concept: NamedNode;
}
/**
* Creates the connection to the db with the parameters passed
Expand All @@ -33,18 +33,11 @@ export async function fetchVocabulariesData() {
const { allConcept } = getQueryConfig(vocab.id);
const queryExecutor = new QueryExecutor(client, vocab.repositoryId, url, username, password, repositoryUrl);

let sparqlQuery = '';

if (vocab.id === 'Chronostratigraphy' || vocab.id === 'TectonicUnits') {
sparqlQuery = allConcept;
} else {
console.warn(`No SPARQL query defined for vocabulary ${vocab.id}`);
continue;
}
let sparqlQuery = allConcept;

try {
console.log(`5 Executing SPARQL query for vocabulary ${vocab.id}`);
const queryResults: QueryResult[] = await queryExecutor.executeSparqlQuery(sparqlQuery);
const queryResults: VocabularyQueryResult [] = await queryExecutor.executeSparqlQuery(sparqlQuery);
/* console.log('Query results:', queryResults); */
results[vocab.id] = queryResults.map(result => ({
label: result.prefLabel.value,
Expand Down Expand Up @@ -88,12 +81,12 @@ export async function fetchVocabolaryTermByQuery(query: string, vocabId: string)

try {
console.log(`7 Executing SPARQL query for vocabulary ${vocab.id}`);
const queryResults: QueryResultNarrowers[] = await queryExecutor.executeSparqlQuery(sparqlQuery);
console.log('Query results:', queryResults);
const queryResults: ConceptQueryResult [] = await queryExecutor.executeSparqlQuery(sparqlQuery);
console.log(`Query results ${vocab.id}:`, queryResults);
for (const result of queryResults) {
results.push(result.narrowerConcept.id);
results.push(result.concept.id);
}
/* console.log(`Successfully fetched data for vocabulary ${vocab.id}:`, results[vocab.id]); */
console.log(`Successfully fetched data for ${vocab.id}:`, results);
} catch (error) {
console.log(`Error fetching data for vocabulary ${vocab.id}:`, error);
throw new Error(`Error fetching data for vocabulary ${vocab.id}: ${error.message}`);
Expand All @@ -102,4 +95,4 @@ export async function fetchVocabolaryTermByQuery(query: string, vocabId: string)
}

return results;
}
}
Loading

0 comments on commit 6b33cb3

Please sign in to comment.