Moved types to folder
This commit is contained in:
@@ -1,50 +1,11 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { ApiResponse } from '@/types/Api'
|
||||||
|
import type { BikeParking } from '@/types/Bikes'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
const BASE_URL = 'https://data.rennesmetropole.fr/api/explore/v2.1/catalog/datasets/parkings_velos_sur_rennes_metropole/records'
|
const BASE_URL = 'https://data.rennesmetropole.fr/api/explore/v2.1/catalog/datasets/parkings_velos_sur_rennes_metropole/records'
|
||||||
const LIMIT = 100
|
const LIMIT = 100
|
||||||
|
|
||||||
interface GeoPoint {
|
|
||||||
lon: number
|
|
||||||
lat: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GeoShape {
|
|
||||||
type: 'Feature'
|
|
||||||
geometry: {
|
|
||||||
coordinates: [number, number]
|
|
||||||
type: 'Point'
|
|
||||||
}
|
|
||||||
properties: Record<string, unknown>
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BikeParking {
|
|
||||||
geo_point_2d: GeoPoint
|
|
||||||
geo_shape: GeoShape
|
|
||||||
gml_id: string
|
|
||||||
id_parc_velo: number
|
|
||||||
nom: string | null
|
|
||||||
code_insee: number
|
|
||||||
nom_commune: string
|
|
||||||
nom_voie: string
|
|
||||||
id_voie: number
|
|
||||||
type: string
|
|
||||||
gestionnaire: string
|
|
||||||
localisation: string
|
|
||||||
condition_acces: string
|
|
||||||
annee_mes: number
|
|
||||||
nb_support_std: number | null
|
|
||||||
nb_support_cargo: number | null
|
|
||||||
nb_total_place: number
|
|
||||||
date_maj: string
|
|
||||||
commentaire: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ApiResponse {
|
|
||||||
total_count: number
|
|
||||||
results: BikeParking[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = ref<BikeParking[]>([])
|
const res = ref<BikeParking[]>([])
|
||||||
|
|
||||||
const firstPage = await fetch(`${BASE_URL}?limit=${LIMIT}`).then(r => r.json()) as ApiResponse
|
const firstPage = await fetch(`${BASE_URL}?limit=${LIMIT}`).then(r => r.json()) as ApiResponse
|
||||||
|
|||||||
6
src/types/Api.ts
Normal file
6
src/types/Api.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import type { BikeParking } from './Bikes'
|
||||||
|
|
||||||
|
export interface ApiResponse {
|
||||||
|
total_count: number
|
||||||
|
results: BikeParking[]
|
||||||
|
}
|
||||||
23
src/types/Bikes.ts
Normal file
23
src/types/Bikes.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import type { GeoPoint, GeoShape } from './Geo'
|
||||||
|
|
||||||
|
export interface BikeParking {
|
||||||
|
geo_point_2d: GeoPoint
|
||||||
|
geo_shape: GeoShape
|
||||||
|
gml_id: string
|
||||||
|
id_parc_velo: number
|
||||||
|
nom: string | null
|
||||||
|
code_insee: number
|
||||||
|
nom_commune: string
|
||||||
|
nom_voie: string
|
||||||
|
id_voie: number
|
||||||
|
type: string
|
||||||
|
gestionnaire: string
|
||||||
|
localisation: string
|
||||||
|
condition_acces: string
|
||||||
|
annee_mes: number
|
||||||
|
nb_support_std: number | null
|
||||||
|
nb_support_cargo: number | null
|
||||||
|
nb_total_place: number
|
||||||
|
date_maj: string
|
||||||
|
commentaire: string | null
|
||||||
|
}
|
||||||
13
src/types/Geo.ts
Normal file
13
src/types/Geo.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export interface GeoPoint {
|
||||||
|
lon: number
|
||||||
|
lat: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GeoShape {
|
||||||
|
type: 'Feature'
|
||||||
|
geometry: {
|
||||||
|
coordinates: [number, number]
|
||||||
|
type: 'Point'
|
||||||
|
}
|
||||||
|
properties: Record<string, unknown>
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user