-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from geoblocks/wip_search
Search plugin
- Loading branch information
Showing
27 changed files
with
461 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Custom app | ||
|
||
This app is a starting point for a fully custom app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import type {CustomConfig} from './ingv-config-custom.js'; | ||
|
||
export const config: CustomConfig = { | ||
languages: ['fr', 'en'], | ||
header: { | ||
title: { | ||
fr: 'Ma custom app', | ||
en: 'My custom app', | ||
}, | ||
searchContext: { | ||
providers: [ | ||
{ | ||
type: 'geoadmin', | ||
options: { | ||
sr: '2056', | ||
limit: 10, | ||
}, | ||
}, | ||
{ | ||
type: 'nominatim', | ||
options: { | ||
limit: 10, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
footer: { | ||
contact: '[email protected]', | ||
impressum: { | ||
fr: 'Bla bla FR impressim', | ||
en: 'Bla bla EN impressim', | ||
}, | ||
}, | ||
app: { | ||
cesiumContext: { | ||
catalogs: { | ||
'@geoadmin': () => import('../../catalogs/geoadminCatalog.js'), | ||
}, | ||
layers: { | ||
imageries: ['@geoadmin/pixel-karte-farbe'], | ||
terrain: '@geoadmin/terrain', | ||
}, | ||
quickLists: { | ||
baseLayers: [ | ||
'@geoadmin/pixel-karte-farbe', | ||
'@geodmin/pixel-karte-frau', | ||
'@geoadmin/swissimage', | ||
], | ||
}, | ||
camera: { | ||
position: [6.628484, 46.5, 1000], | ||
orientation: { | ||
heading: 0, | ||
pitch: -30.0, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/logo.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>My custom application</title> | ||
<!-- <link rel="stylesheet" href="./src/index.css" /> --> | ||
<script type="module" src="./index.ts"></script> | ||
|
||
<style> | ||
/* FIXME: move to default style */ | ||
html { | ||
box-sizing: border-box; | ||
} | ||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: inherit; | ||
} | ||
body { | ||
margin: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<noscript>Enable JS!</noscript> | ||
<ngv-app-custom></ngv-app-custom> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type {HTMLTemplateResult} from 'lit'; | ||
import {html} from 'lit'; | ||
import {customElement} from 'lit/decorators.js'; | ||
|
||
import '../../structure/ngv-structure-app.js'; | ||
|
||
// // @ts-expect-error ?url parameter is a viteJS specificity | ||
// import logoUrl from "../../logo.svg?url"; | ||
import {localized} from '@lit/localize'; | ||
import {ABaseApp} from '../../structure/BaseApp.js'; | ||
|
||
import './ngv-main-custom.js'; | ||
|
||
import type {CustomConfig} from './ingv-config-custom.js'; | ||
|
||
@customElement('ngv-app-custom') | ||
@localized() | ||
export class NgvAppCustom extends ABaseApp<CustomConfig> { | ||
constructor() { | ||
super(() => import('./customConfig.js')); | ||
} | ||
|
||
render(): HTMLTemplateResult { | ||
const r = super.render(); | ||
if (r && !this.config) { | ||
// todo check | ||
return r; | ||
} | ||
return html` | ||
<ngv-structure-app .config=${this.config}> | ||
<ngv-main-custom .config=${this.config?.app}></ngv-main-custom> | ||
</ngv-structure-app> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type {IngvCesiumContext} from '../../interfaces/cesium/ingv-cesium-context.js'; | ||
import type {INgvStructureApp} from '../../structure/ngv-structure-app.js'; | ||
|
||
export interface CustomConfig extends INgvStructureApp { | ||
app: { | ||
cesiumContext: IngvCesiumContext; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {customElement, property} from 'lit/decorators.js'; | ||
import type {HTMLTemplateResult} from 'lit'; | ||
import {html, LitElement} from 'lit'; | ||
import type {CustomConfig} from './ingv-config-custom.js'; | ||
|
||
import '../../plugins/cesium/ngv-plugin-cesium-widget.js'; | ||
|
||
@customElement('ngv-main-custom') | ||
export class NgvMainCustom extends LitElement { | ||
@property({type: Object}) | ||
config: CustomConfig['app']; | ||
|
||
protected render(): HTMLTemplateResult { | ||
return html` <div class="app-container">Nice app implementation</div> `; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'ngv-main-custom': NgvMainCustom; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type {INGVSearchProviderConfigs} from './ingv-search-provider.js'; | ||
|
||
export interface IngvSearchContext { | ||
providers: INGVSearchProviderConfigs[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type {Geometry} from 'geojson'; | ||
|
||
/** | ||
* To add a providers, you need to: | ||
* 1. Create a new provider file in src/plugins/search/providers/ that implements the INGVSearchProvider interface | ||
* 2. Add the provider to the getProvider function in src/plugins/search/ngv-search-providers.ts | ||
* 3. Add the provider to the IngvSearchContext in src/interfaces/search/ingv-search-context.ts | ||
*/ | ||
|
||
export interface INGVSearchResult { | ||
title: string; | ||
|
||
geom: Geometry; | ||
|
||
// From which provider the result comes from | ||
provider: string; | ||
|
||
// The provider-specific category, if provided | ||
category?: string | null; | ||
|
||
extra?: Record<string, any>; | ||
} | ||
|
||
export interface INGVGeoAdminSearchProviderConfig { | ||
type: 'geoadmin'; | ||
|
||
options?: { | ||
sr?: string; | ||
limit?: number; | ||
locationOrigins?: string; | ||
}; | ||
} | ||
|
||
export function isGeoAdminSearchProvider( | ||
config: INGVSearchProviderConfigs, | ||
): config is INGVGeoAdminSearchProviderConfig { | ||
return config.type === 'geoadmin'; | ||
} | ||
|
||
export interface INGVNominatimSearchProviderConfig { | ||
type: 'nominatim'; | ||
|
||
options?: { | ||
/** URL to the Nominatim search API. The following placeholders are supported: | ||
* - `{input}`: the search query | ||
* - `{lang}`: the language code | ||
* - `{limit}`: see below | ||
*/ | ||
url?: string; | ||
|
||
/** Maximum number of results to return */ | ||
limit?: number; | ||
}; | ||
} | ||
export function isNominatimSearchProvider( | ||
config: INGVSearchProviderConfigs, | ||
): config is INGVNominatimSearchProviderConfig { | ||
return config.type === 'nominatim'; | ||
} | ||
|
||
// Unions of all possible configs | ||
export type INGVSearchProviderConfigs = | ||
| INGVGeoAdminSearchProviderConfig | ||
| INGVNominatimSearchProviderConfig; | ||
|
||
export interface INGVSearchProvider { | ||
search: (input: string, lang: string) => Promise<INGVSearchResult[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.