@ignfab/geocontext 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -257
- package/dist/gpf/adminexpress.d.ts +17 -8
- package/dist/gpf/adminexpress.js +40 -17
- package/dist/gpf/adminexpress.js.map +1 -1
- package/dist/gpf/altitude.d.ts +21 -9
- package/dist/gpf/altitude.js +5 -5
- package/dist/gpf/altitude.js.map +1 -1
- package/dist/gpf/geocode.d.ts +25 -4
- package/dist/gpf/geocode.js +5 -5
- package/dist/gpf/geocode.js.map +1 -1
- package/dist/gpf/parcellaire-express.d.ts +19 -9
- package/dist/gpf/parcellaire-express.js +59 -26
- package/dist/gpf/parcellaire-express.js.map +1 -1
- package/dist/gpf/urbanisme.d.ts +24 -16
- package/dist/gpf/urbanisme.js +81 -33
- package/dist/gpf/urbanisme.js.map +1 -1
- package/dist/gpf/{wfs.js → wfs-schema-catalog.js} +1 -1
- package/dist/gpf/wfs-schema-catalog.js.map +1 -0
- package/dist/helpers/RateLimiter.d.ts +44 -0
- package/dist/helpers/RateLimiter.js +52 -0
- package/dist/helpers/RateLimiter.js.map +1 -0
- package/dist/helpers/distance.d.ts +2 -1
- package/dist/helpers/distance.js +2 -1
- package/dist/helpers/distance.js.map +1 -1
- package/dist/helpers/errors/toolError.d.ts +30 -0
- package/dist/helpers/errors/toolError.js +193 -0
- package/dist/helpers/errors/toolError.js.map +1 -0
- package/dist/helpers/errors/zodErrorMapFr.d.ts +20 -0
- package/dist/helpers/errors/zodErrorMapFr.js +191 -0
- package/dist/helpers/errors/zodErrorMapFr.js.map +1 -0
- package/dist/helpers/http.d.ts +67 -7
- package/dist/helpers/http.js +458 -84
- package/dist/helpers/http.js.map +1 -1
- package/dist/helpers/jsonSchema.d.ts +16 -4
- package/dist/helpers/jsonSchema.js +7 -1
- package/dist/helpers/jsonSchema.js.map +1 -1
- package/dist/helpers/schemas.d.ts +4 -4
- package/dist/helpers/wfs_engine/attributeFilter.d.ts +51 -0
- package/dist/helpers/wfs_engine/attributeFilter.js +258 -0
- package/dist/helpers/wfs_engine/attributeFilter.js.map +1 -0
- package/dist/helpers/wfs_engine/byId.d.ts +76 -0
- package/dist/helpers/wfs_engine/byId.js +106 -0
- package/dist/helpers/wfs_engine/byId.js.map +1 -0
- package/dist/helpers/wfs_engine/execution.d.ts +72 -0
- package/dist/helpers/wfs_engine/execution.js +95 -0
- package/dist/helpers/wfs_engine/execution.js.map +1 -0
- package/dist/helpers/wfs_engine/features.d.ts +64 -0
- package/dist/helpers/wfs_engine/features.js +138 -0
- package/dist/helpers/wfs_engine/features.js.map +1 -0
- package/dist/helpers/wfs_engine/geometry.d.ts +16 -0
- package/dist/helpers/wfs_engine/geometry.js +44 -0
- package/dist/helpers/wfs_engine/geometry.js.map +1 -0
- package/dist/helpers/wfs_engine/properties.d.ts +51 -0
- package/dist/helpers/wfs_engine/properties.js +128 -0
- package/dist/helpers/wfs_engine/properties.js.map +1 -0
- package/dist/helpers/wfs_engine/queryPreparation.d.ts +32 -0
- package/dist/helpers/wfs_engine/queryPreparation.js +149 -0
- package/dist/helpers/wfs_engine/queryPreparation.js.map +1 -0
- package/dist/helpers/{wfs_internal → wfs_engine}/request.d.ts +49 -2
- package/dist/helpers/{wfs_internal → wfs_engine}/request.js +77 -1
- package/dist/helpers/wfs_engine/request.js.map +1 -0
- package/dist/helpers/wfs_engine/response.d.ts +80 -0
- package/dist/helpers/wfs_engine/response.js +135 -0
- package/dist/helpers/wfs_engine/response.js.map +1 -0
- package/dist/helpers/wfs_engine/schema.d.ts +209 -0
- package/dist/helpers/{wfs_internal → wfs_engine}/schema.js +50 -10
- package/dist/helpers/wfs_engine/schema.js.map +1 -0
- package/dist/helpers/wfs_engine/spatialCql.d.ts +46 -0
- package/dist/helpers/wfs_engine/spatialCql.js +54 -0
- package/dist/helpers/wfs_engine/spatialCql.js.map +1 -0
- package/dist/helpers/wfs_engine/spatialFilter.d.ts +14 -0
- package/dist/helpers/wfs_engine/spatialFilter.js +131 -0
- package/dist/helpers/wfs_engine/spatialFilter.js.map +1 -0
- package/dist/index.js +65 -23
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +4 -1
- package/dist/logger.js.map +1 -1
- package/dist/tools/AdminexpressTool.d.ts +42 -33
- package/dist/tools/AdminexpressTool.js +17 -2
- package/dist/tools/AdminexpressTool.js.map +1 -1
- package/dist/tools/AltitudeTool.d.ts +35 -44
- package/dist/tools/AltitudeTool.js +19 -8
- package/dist/tools/AltitudeTool.js.map +1 -1
- package/dist/tools/AssietteSupTool.d.ts +51 -34
- package/dist/tools/AssietteSupTool.js +17 -2
- package/dist/tools/AssietteSupTool.js.map +1 -1
- package/dist/tools/BaseTool.d.ts +17 -0
- package/dist/tools/BaseTool.js +41 -0
- package/dist/tools/BaseTool.js.map +1 -0
- package/dist/tools/CadastreTool.d.ts +53 -33
- package/dist/tools/CadastreTool.js +17 -2
- package/dist/tools/CadastreTool.js.map +1 -1
- package/dist/tools/GeocodeTool.d.ts +53 -37
- package/dist/tools/GeocodeTool.js +17 -2
- package/dist/tools/GeocodeTool.js.map +1 -1
- package/dist/tools/GpfWfsDescribeTypeTool.d.ts +66 -94
- package/dist/tools/GpfWfsDescribeTypeTool.js +25 -14
- package/dist/tools/GpfWfsDescribeTypeTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeatureByIdTool.d.ts +52 -73
- package/dist/tools/GpfWfsGetFeatureByIdTool.js +50 -107
- package/dist/tools/GpfWfsGetFeatureByIdTool.js.map +1 -1
- package/dist/tools/GpfWfsGetFeaturesTool.d.ts +89 -114
- package/dist/tools/GpfWfsGetFeaturesTool.js +29 -120
- package/dist/tools/GpfWfsGetFeaturesTool.js.map +1 -1
- package/dist/tools/GpfWfsSearchTypesTool.d.ts +41 -32
- package/dist/tools/GpfWfsSearchTypesTool.js +18 -3
- package/dist/tools/GpfWfsSearchTypesTool.js.map +1 -1
- package/dist/tools/UrbanismeTool.d.ts +42 -33
- package/dist/tools/UrbanismeTool.js +17 -2
- package/dist/tools/UrbanismeTool.js.map +1 -1
- package/package.json +51 -24
- package/dist/gpf/wfs.js.map +0 -1
- package/dist/helpers/wfs.d.ts +0 -27
- package/dist/helpers/wfs.js +0 -55
- package/dist/helpers/wfs.js.map +0 -1
- package/dist/helpers/wfs_internal/compile.d.ts +0 -55
- package/dist/helpers/wfs_internal/compile.js +0 -596
- package/dist/helpers/wfs_internal/compile.js.map +0 -1
- package/dist/helpers/wfs_internal/request.js.map +0 -1
- package/dist/helpers/wfs_internal/response.d.ts +0 -29
- package/dist/helpers/wfs_internal/response.js +0 -59
- package/dist/helpers/wfs_internal/response.js.map +0 -1
- package/dist/helpers/wfs_internal/schema.d.ts +0 -167
- package/dist/helpers/wfs_internal/schema.js.map +0 -1
- /package/dist/gpf/{wfs.d.ts → wfs-schema-catalog.d.ts} +0 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas and published MCP input schemas for the structured WFS engine.
|
|
3
|
+
*
|
|
4
|
+
* This module centralizes:
|
|
5
|
+
* - shared schema fragments reused by WFS tools
|
|
6
|
+
* - public tool input schemas and inferred input types
|
|
7
|
+
* - compact output schemas used for `hits` and `request` responses
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export declare const DEFAULT_LIMIT = 100;
|
|
11
|
+
export declare const MAX_LIMIT = 5000;
|
|
12
|
+
export declare const REQUEST_GET_URL_MAX_LENGTH = 6000;
|
|
13
|
+
export declare const WHERE_OPERATORS: readonly ["eq", "ne", "lt", "lte", "gt", "gte", "in", "is_null"];
|
|
14
|
+
export declare const SPATIAL_OPERATORS: readonly ["bbox", "intersects_point", "dwithin_point", "intersects_feature"];
|
|
15
|
+
export declare const ORDER_DIRECTIONS: readonly ["asc", "desc"];
|
|
16
|
+
export type SpatialFilter = {
|
|
17
|
+
operator: "bbox";
|
|
18
|
+
west: number;
|
|
19
|
+
south: number;
|
|
20
|
+
east: number;
|
|
21
|
+
north: number;
|
|
22
|
+
} | {
|
|
23
|
+
operator: "intersects_point";
|
|
24
|
+
lon: number;
|
|
25
|
+
lat: number;
|
|
26
|
+
} | {
|
|
27
|
+
operator: "dwithin_point";
|
|
28
|
+
lon: number;
|
|
29
|
+
lat: number;
|
|
30
|
+
distance_m: number;
|
|
31
|
+
} | {
|
|
32
|
+
operator: "intersects_feature";
|
|
33
|
+
typename: string;
|
|
34
|
+
feature_id: string;
|
|
35
|
+
};
|
|
36
|
+
export declare const gpfWfsGetFeaturesRequestOutputSchema: z.ZodObject<{
|
|
37
|
+
result_type: z.ZodLiteral<"request">;
|
|
38
|
+
method: z.ZodLiteral<"POST">;
|
|
39
|
+
url: z.ZodString;
|
|
40
|
+
query: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
41
|
+
body: z.ZodString;
|
|
42
|
+
get_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
url: string;
|
|
45
|
+
result_type: "request";
|
|
46
|
+
method: "POST";
|
|
47
|
+
query: Record<string, string>;
|
|
48
|
+
body: string;
|
|
49
|
+
get_url?: string | null | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
url: string;
|
|
52
|
+
result_type: "request";
|
|
53
|
+
method: "POST";
|
|
54
|
+
query: Record<string, string>;
|
|
55
|
+
body: string;
|
|
56
|
+
get_url?: string | null | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
export declare const gpfWfsGetFeatureByIdRequestOutputSchema: z.ZodObject<{
|
|
59
|
+
result_type: z.ZodLiteral<"request">;
|
|
60
|
+
method: z.ZodLiteral<"POST">;
|
|
61
|
+
url: z.ZodString;
|
|
62
|
+
query: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
63
|
+
body: z.ZodString;
|
|
64
|
+
get_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
url: string;
|
|
67
|
+
result_type: "request";
|
|
68
|
+
method: "POST";
|
|
69
|
+
query: Record<string, string>;
|
|
70
|
+
body: string;
|
|
71
|
+
get_url?: string | null | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
url: string;
|
|
74
|
+
result_type: "request";
|
|
75
|
+
method: "POST";
|
|
76
|
+
query: Record<string, string>;
|
|
77
|
+
body: string;
|
|
78
|
+
get_url?: string | null | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
export declare const gpfWfsGetFeaturesInputSchema: z.ZodObject<{
|
|
81
|
+
typename: z.ZodString;
|
|
82
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
83
|
+
result_type: z.ZodDefault<z.ZodEnum<["results", "hits", "request"]>>;
|
|
84
|
+
select: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
85
|
+
order_by: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
86
|
+
property: z.ZodString;
|
|
87
|
+
direction: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
88
|
+
}, "strict", z.ZodTypeAny, {
|
|
89
|
+
property: string;
|
|
90
|
+
direction: "asc" | "desc";
|
|
91
|
+
}, {
|
|
92
|
+
property: string;
|
|
93
|
+
direction?: "asc" | "desc" | undefined;
|
|
94
|
+
}>, "many">>;
|
|
95
|
+
where: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
96
|
+
property: z.ZodString;
|
|
97
|
+
operator: z.ZodEnum<["eq", "ne", "lt", "lte", "gt", "gte", "in", "is_null"]>;
|
|
98
|
+
value: z.ZodOptional<z.ZodString>;
|
|
99
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
100
|
+
}, "strict", z.ZodTypeAny, {
|
|
101
|
+
property: string;
|
|
102
|
+
operator: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
103
|
+
values?: string[] | undefined;
|
|
104
|
+
value?: string | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
property: string;
|
|
107
|
+
operator: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
108
|
+
values?: string[] | undefined;
|
|
109
|
+
value?: string | undefined;
|
|
110
|
+
}>, "many">>;
|
|
111
|
+
spatial_operator: z.ZodOptional<z.ZodEnum<["bbox", "intersects_point", "dwithin_point", "intersects_feature"]>>;
|
|
112
|
+
bbox_west: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
bbox_south: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
bbox_east: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
bbox_north: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
intersects_lon: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
intersects_lat: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
dwithin_lon: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
dwithin_lat: z.ZodOptional<z.ZodNumber>;
|
|
120
|
+
dwithin_distance_m: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
intersects_feature_typename: z.ZodOptional<z.ZodString>;
|
|
122
|
+
intersects_feature_id: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, "strict", z.ZodTypeAny, {
|
|
124
|
+
typename: string;
|
|
125
|
+
result_type: "request" | "results" | "hits";
|
|
126
|
+
limit: number;
|
|
127
|
+
select?: string[] | undefined;
|
|
128
|
+
order_by?: {
|
|
129
|
+
property: string;
|
|
130
|
+
direction: "asc" | "desc";
|
|
131
|
+
}[] | undefined;
|
|
132
|
+
where?: {
|
|
133
|
+
property: string;
|
|
134
|
+
operator: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
135
|
+
values?: string[] | undefined;
|
|
136
|
+
value?: string | undefined;
|
|
137
|
+
}[] | undefined;
|
|
138
|
+
spatial_operator?: "bbox" | "intersects_point" | "dwithin_point" | "intersects_feature" | undefined;
|
|
139
|
+
bbox_west?: number | undefined;
|
|
140
|
+
bbox_south?: number | undefined;
|
|
141
|
+
bbox_east?: number | undefined;
|
|
142
|
+
bbox_north?: number | undefined;
|
|
143
|
+
intersects_lon?: number | undefined;
|
|
144
|
+
intersects_lat?: number | undefined;
|
|
145
|
+
dwithin_lon?: number | undefined;
|
|
146
|
+
dwithin_lat?: number | undefined;
|
|
147
|
+
dwithin_distance_m?: number | undefined;
|
|
148
|
+
intersects_feature_typename?: string | undefined;
|
|
149
|
+
intersects_feature_id?: string | undefined;
|
|
150
|
+
}, {
|
|
151
|
+
typename: string;
|
|
152
|
+
result_type?: "request" | "results" | "hits" | undefined;
|
|
153
|
+
limit?: number | undefined;
|
|
154
|
+
select?: string[] | undefined;
|
|
155
|
+
order_by?: {
|
|
156
|
+
property: string;
|
|
157
|
+
direction?: "asc" | "desc" | undefined;
|
|
158
|
+
}[] | undefined;
|
|
159
|
+
where?: {
|
|
160
|
+
property: string;
|
|
161
|
+
operator: "gte" | "gt" | "lte" | "lt" | "eq" | "ne" | "in" | "is_null";
|
|
162
|
+
values?: string[] | undefined;
|
|
163
|
+
value?: string | undefined;
|
|
164
|
+
}[] | undefined;
|
|
165
|
+
spatial_operator?: "bbox" | "intersects_point" | "dwithin_point" | "intersects_feature" | undefined;
|
|
166
|
+
bbox_west?: number | undefined;
|
|
167
|
+
bbox_south?: number | undefined;
|
|
168
|
+
bbox_east?: number | undefined;
|
|
169
|
+
bbox_north?: number | undefined;
|
|
170
|
+
intersects_lon?: number | undefined;
|
|
171
|
+
intersects_lat?: number | undefined;
|
|
172
|
+
dwithin_lon?: number | undefined;
|
|
173
|
+
dwithin_lat?: number | undefined;
|
|
174
|
+
dwithin_distance_m?: number | undefined;
|
|
175
|
+
intersects_feature_typename?: string | undefined;
|
|
176
|
+
intersects_feature_id?: string | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
export type GpfWfsGetFeaturesInput = z.infer<typeof gpfWfsGetFeaturesInputSchema>;
|
|
179
|
+
export type WhereClause = NonNullable<GpfWfsGetFeaturesInput["where"]>[number];
|
|
180
|
+
export type OrderByClause = NonNullable<GpfWfsGetFeaturesInput["order_by"]>[number];
|
|
181
|
+
export declare const gpfWfsGetFeaturesHitsOutputSchema: z.ZodObject<{
|
|
182
|
+
result_type: z.ZodLiteral<"hits">;
|
|
183
|
+
totalFeatures: z.ZodNumber;
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
result_type: "hits";
|
|
186
|
+
totalFeatures: number;
|
|
187
|
+
}, {
|
|
188
|
+
result_type: "hits";
|
|
189
|
+
totalFeatures: number;
|
|
190
|
+
}>;
|
|
191
|
+
export declare const gpfWfsGetFeaturesPublishedInputSchema: import("../jsonSchema.js").PublishedInputSchema;
|
|
192
|
+
export declare const gpfWfsGetFeatureByIdInputSchema: z.ZodObject<{
|
|
193
|
+
typename: z.ZodString;
|
|
194
|
+
feature_id: z.ZodString;
|
|
195
|
+
result_type: z.ZodDefault<z.ZodEnum<["results", "request"]>>;
|
|
196
|
+
select: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
197
|
+
}, "strict", z.ZodTypeAny, {
|
|
198
|
+
typename: string;
|
|
199
|
+
feature_id: string;
|
|
200
|
+
result_type: "request" | "results";
|
|
201
|
+
select?: string[] | undefined;
|
|
202
|
+
}, {
|
|
203
|
+
typename: string;
|
|
204
|
+
feature_id: string;
|
|
205
|
+
result_type?: "request" | "results" | undefined;
|
|
206
|
+
select?: string[] | undefined;
|
|
207
|
+
}>;
|
|
208
|
+
export type GpfWfsGetFeatureByIdInput = z.infer<typeof gpfWfsGetFeatureByIdInputSchema>;
|
|
209
|
+
export declare const gpfWfsGetFeatureByIdPublishedInputSchema: import("../jsonSchema.js").PublishedInputSchema;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas and published MCP input schemas for the structured WFS engine.
|
|
3
|
+
*
|
|
4
|
+
* This module centralizes:
|
|
5
|
+
* - shared schema fragments reused by WFS tools
|
|
6
|
+
* - public tool input schemas and inferred input types
|
|
7
|
+
* - compact output schemas used for `hits` and `request` responses
|
|
8
|
+
*/
|
|
1
9
|
import { z } from "zod";
|
|
2
|
-
import { generatePublishedInputSchema } from "
|
|
3
|
-
import { lonSchema, latSchema } from "
|
|
10
|
+
import { generatePublishedInputSchema } from "../jsonSchema.js";
|
|
11
|
+
import { lonSchema, latSchema } from "../schemas.js";
|
|
12
|
+
// --- Shared Constants ---
|
|
4
13
|
export const DEFAULT_LIMIT = 100;
|
|
5
14
|
export const MAX_LIMIT = 5000;
|
|
6
15
|
export const REQUEST_GET_URL_MAX_LENGTH = 6000;
|
|
7
16
|
export const WHERE_OPERATORS = ["eq", "ne", "lt", "lte", "gt", "gte", "in", "is_null"];
|
|
8
17
|
export const SPATIAL_OPERATORS = ["bbox", "intersects_point", "dwithin_point", "intersects_feature"];
|
|
9
18
|
export const ORDER_DIRECTIONS = ["asc", "desc"];
|
|
19
|
+
// --- Shared Clauses ---
|
|
10
20
|
const whereClauseSchema = z.object({
|
|
11
21
|
property: z.string().trim().min(1).describe("Nom exact d'une propriété non géométrique du type WFS. Utiliser `gpf_wfs_describe_type` pour connaître les noms exacts disponibles."),
|
|
12
22
|
operator: z.enum(WHERE_OPERATORS).describe("Opérateur de filtre : `eq`, `ne`, `lt`, `lte`, `gt`, `gte`, `in`, `is_null`."),
|
|
@@ -17,6 +27,18 @@ const orderBySchema = z.object({
|
|
|
17
27
|
property: z.string().trim().min(1).describe("Nom exact d'une propriété non géométrique à utiliser pour le tri. Utiliser `gpf_wfs_describe_type` pour connaître les noms exacts disponibles."),
|
|
18
28
|
direction: z.enum(ORDER_DIRECTIONS).default("asc").describe("Direction de tri : `asc` ou `desc`."),
|
|
19
29
|
}).strict().describe("Critère de tri structuré. Exemple : `{ property: \"population\", direction: \"desc\" }`.");
|
|
30
|
+
// --- Shared Compact Outputs ---
|
|
31
|
+
const wfsRequestOutputSchema = z.object({
|
|
32
|
+
result_type: z.literal("request").describe("Indique que la réponse contient la requête WFS compilée (équivalent enrichi géométrie pour `create_map` et le débogage)."),
|
|
33
|
+
method: z.literal("POST").describe("Méthode HTTP réellement utilisée pour exécuter la requête."),
|
|
34
|
+
url: z.string().describe("URL de base appelée pour la requête POST."),
|
|
35
|
+
query: z.record(z.string()).describe("Paramètres WFS envoyés dans la query string."),
|
|
36
|
+
body: z.string().describe("Corps de la requête POST, encodé en `application/x-www-form-urlencoded`."),
|
|
37
|
+
get_url: z.string().nullable().optional().describe("URL GET dérivée quand la requête reste raisonnablement portable en GET."),
|
|
38
|
+
});
|
|
39
|
+
export const gpfWfsGetFeaturesRequestOutputSchema = wfsRequestOutputSchema;
|
|
40
|
+
export const gpfWfsGetFeatureByIdRequestOutputSchema = wfsRequestOutputSchema;
|
|
41
|
+
// --- `gpf_wfs_get_features` ---
|
|
20
42
|
export const gpfWfsGetFeaturesInputSchema = z.object({
|
|
21
43
|
typename: z
|
|
22
44
|
.string()
|
|
@@ -65,17 +87,35 @@ export const gpfWfsGetFeaturesInputSchema = z.object({
|
|
|
65
87
|
intersects_feature_typename: z.string().trim().min(1).optional().describe("Type WFS du feature de référence, utilisé avec `spatial_operator = \"intersects_feature\"`."),
|
|
66
88
|
intersects_feature_id: z.string().trim().min(1).optional().describe("Identifiant du feature de référence, utilisé avec `spatial_operator = \"intersects_feature\"`."),
|
|
67
89
|
}).strict();
|
|
90
|
+
// --- `gpf_wfs_get_features` Outputs ---
|
|
68
91
|
export const gpfWfsGetFeaturesHitsOutputSchema = z.object({
|
|
69
92
|
result_type: z.literal("hits").describe("Indique que la réponse contient uniquement un comptage."),
|
|
70
93
|
totalFeatures: z.number().describe("Le nombre total d'objets correspondant à la requête."),
|
|
71
94
|
});
|
|
72
|
-
|
|
73
|
-
result_type: z.literal("request").describe("Indique que la réponse contient la requête WFS compilée (équivalent enrichi géométrie pour `create_map` et le débogage)."),
|
|
74
|
-
method: z.literal("POST").describe("Méthode HTTP réellement utilisée pour exécuter la requête."),
|
|
75
|
-
url: z.string().describe("URL de base appelée pour la requête POST."),
|
|
76
|
-
query: z.record(z.string()).describe("Paramètres WFS envoyés dans la query string."),
|
|
77
|
-
body: z.string().describe("Corps de la requête POST, encodé en `application/x-www-form-urlencoded`."),
|
|
78
|
-
get_url: z.string().nullable().optional().describe("URL GET dérivée quand la requête reste raisonnablement portable en GET."),
|
|
79
|
-
});
|
|
95
|
+
// --- `gpf_wfs_get_features` Published Schema ---
|
|
80
96
|
export const gpfWfsGetFeaturesPublishedInputSchema = generatePublishedInputSchema(gpfWfsGetFeaturesInputSchema);
|
|
97
|
+
// --- `gpf_wfs_get_feature_by_id` ---
|
|
98
|
+
export const gpfWfsGetFeatureByIdInputSchema = z.object({
|
|
99
|
+
typename: z
|
|
100
|
+
.string()
|
|
101
|
+
.trim()
|
|
102
|
+
.min(1, "le nom du type ne doit pas être vide")
|
|
103
|
+
.describe("Nom exact du type WFS à interroger, par exemple `ADMINEXPRESS-COG.LATEST:commune`."),
|
|
104
|
+
feature_id: z
|
|
105
|
+
.string()
|
|
106
|
+
.trim()
|
|
107
|
+
.min(1, "le feature_id ne doit pas être vide")
|
|
108
|
+
.describe("Identifiant WFS exact de l'objet à récupérer, par exemple `commune.8952`."),
|
|
109
|
+
result_type: z
|
|
110
|
+
.enum(["results", "request"])
|
|
111
|
+
.default("results")
|
|
112
|
+
.describe("`results` renvoie une FeatureCollection normalisée avec exactement un objet. `request` renvoie la requête WFS compilée (`get_url`) à destination de `create_map` via `geojson_url`, ou pour déboguer."),
|
|
113
|
+
select: z
|
|
114
|
+
.array(z.string().trim().min(1))
|
|
115
|
+
.min(1)
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("Liste des propriétés non géométriques à renvoyer. Quand `result_type=\"request\"`, la géométrie est automatiquement ajoutée."),
|
|
118
|
+
}).strict();
|
|
119
|
+
// --- `gpf_wfs_get_feature_by_id` Published Schema ---
|
|
120
|
+
export const gpfWfsGetFeatureByIdPublishedInputSchema = generatePublishedInputSchema(gpfWfsGetFeatureByIdInputSchema);
|
|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AyD,CAAC;IAClG,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;CAC3F,CAAC,CAAC;AAEH,kDAAkD;AAElD,MAAM,CAAC,MAAM,qCAAqC,GAAG,4BAA4B,CAAC,4BAA4B,CAAC,CAAC;AAEhH,sCAAsC;AAEtC,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,sCAAsC,CAAC;SAC9C,QAAQ,CAAC,oFAAoF,CAAC;IACjG,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,qCAAqC,CAAC;SAC7C,QAAQ,CAAC,2EAA2E,CAAC;IACxF,WAAW,EAAE,CAAC;SACX,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;SAC5B,OAAO,CAAC,SAAS,CAAC;SAClB,QAAQ,CAAC,uMAAuM,CAAC;IACpN,MAAM,EAAE,CAAC;SACN,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC/B,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,EAAE;SACV,QAAQ,CAAC,8HAA8H,CAAC;CAC5I,CAAC,CAAC,MAAM,EAAE,CAAC;AAMZ,uDAAuD;AAEvD,MAAM,CAAC,MAAM,wCAAwC,GAAG,4BAA4B,CAAC,+BAA+B,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial CQL compilation helpers for the structured WFS query compiler.
|
|
3
|
+
*
|
|
4
|
+
* This module turns normalized spatial filter objects into CQL fragments that
|
|
5
|
+
* can be combined with attribute predicates in the final query.
|
|
6
|
+
*/
|
|
7
|
+
import type { CollectionProperty } from "@ignfab/gpf-schema-store";
|
|
8
|
+
import type { SpatialFilter } from "./schema.js";
|
|
9
|
+
/**
|
|
10
|
+
* Compiles a bbox spatial filter into a CQL predicate.
|
|
11
|
+
*
|
|
12
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
13
|
+
* @param spatialFilter Normalized bbox filter.
|
|
14
|
+
* @returns A CQL bbox predicate.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compileBboxSpatialFilter(geometryProperty: CollectionProperty, spatialFilter: Extract<SpatialFilter, {
|
|
17
|
+
operator: "bbox";
|
|
18
|
+
}>): string;
|
|
19
|
+
/**
|
|
20
|
+
* Compiles an intersects-point spatial filter into a CQL predicate.
|
|
21
|
+
*
|
|
22
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
23
|
+
* @param spatialFilter Normalized point intersection filter.
|
|
24
|
+
* @returns A CQL intersects predicate.
|
|
25
|
+
*/
|
|
26
|
+
export declare function compileIntersectsPointSpatialFilter(geometryProperty: CollectionProperty, spatialFilter: Extract<SpatialFilter, {
|
|
27
|
+
operator: "intersects_point";
|
|
28
|
+
}>): string;
|
|
29
|
+
/**
|
|
30
|
+
* Compiles a distance-based spatial filter into a CQL predicate.
|
|
31
|
+
*
|
|
32
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
33
|
+
* @param spatialFilter Normalized distance filter.
|
|
34
|
+
* @returns A CQL dwithin predicate.
|
|
35
|
+
*/
|
|
36
|
+
export declare function compileDwithinSpatialFilter(geometryProperty: CollectionProperty, spatialFilter: Extract<SpatialFilter, {
|
|
37
|
+
operator: "dwithin_point";
|
|
38
|
+
}>): string;
|
|
39
|
+
/**
|
|
40
|
+
* Compiles an `intersects_feature` spatial filter once the reference geometry is already serialized.
|
|
41
|
+
*
|
|
42
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
43
|
+
* @param geometryEwkt Reference geometry serialized as EWKT.
|
|
44
|
+
* @returns A CQL intersects predicate.
|
|
45
|
+
*/
|
|
46
|
+
export declare function compileIntersectsFeatureSpatialFilter(geometryProperty: CollectionProperty, geometryEwkt: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial CQL compilation helpers for the structured WFS query compiler.
|
|
3
|
+
*
|
|
4
|
+
* This module turns normalized spatial filter objects into CQL fragments that
|
|
5
|
+
* can be combined with attribute predicates in the final query.
|
|
6
|
+
*/
|
|
7
|
+
// --- Spatial Predicate Compilation ---
|
|
8
|
+
/**
|
|
9
|
+
* Compiles a bbox spatial filter into a CQL predicate.
|
|
10
|
+
*
|
|
11
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
12
|
+
* @param spatialFilter Normalized bbox filter.
|
|
13
|
+
* @returns A CQL bbox predicate.
|
|
14
|
+
*/
|
|
15
|
+
export function compileBboxSpatialFilter(geometryProperty, spatialFilter) {
|
|
16
|
+
if (spatialFilter.west >= spatialFilter.east) {
|
|
17
|
+
throw new Error("Le bbox est invalide : `bbox_west` doit être strictement inférieur à `bbox_east`.");
|
|
18
|
+
}
|
|
19
|
+
if (spatialFilter.south >= spatialFilter.north) {
|
|
20
|
+
throw new Error("Le bbox est invalide : `bbox_south` doit être strictement inférieur à `bbox_north`.");
|
|
21
|
+
}
|
|
22
|
+
return `BBOX(${geometryProperty.name},${spatialFilter.west},${spatialFilter.south},${spatialFilter.east},${spatialFilter.north},'EPSG:4326')`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compiles an intersects-point spatial filter into a CQL predicate.
|
|
26
|
+
*
|
|
27
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
28
|
+
* @param spatialFilter Normalized point intersection filter.
|
|
29
|
+
* @returns A CQL intersects predicate.
|
|
30
|
+
*/
|
|
31
|
+
export function compileIntersectsPointSpatialFilter(geometryProperty, spatialFilter) {
|
|
32
|
+
return `INTERSECTS(${geometryProperty.name},SRID=4326;POINT(${spatialFilter.lon} ${spatialFilter.lat}))`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Compiles a distance-based spatial filter into a CQL predicate.
|
|
36
|
+
*
|
|
37
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
38
|
+
* @param spatialFilter Normalized distance filter.
|
|
39
|
+
* @returns A CQL dwithin predicate.
|
|
40
|
+
*/
|
|
41
|
+
export function compileDwithinSpatialFilter(geometryProperty, spatialFilter) {
|
|
42
|
+
return `DWITHIN(${geometryProperty.name},SRID=4326;POINT(${spatialFilter.lon} ${spatialFilter.lat}),${spatialFilter.distance_m},meters)`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Compiles an `intersects_feature` spatial filter once the reference geometry is already serialized.
|
|
46
|
+
*
|
|
47
|
+
* @param geometryProperty Geometry property already resolved for the feature type.
|
|
48
|
+
* @param geometryEwkt Reference geometry serialized as EWKT.
|
|
49
|
+
* @returns A CQL intersects predicate.
|
|
50
|
+
*/
|
|
51
|
+
export function compileIntersectsFeatureSpatialFilter(geometryProperty, geometryEwkt) {
|
|
52
|
+
return `INTERSECTS(${geometryProperty.name},${geometryEwkt})`;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=spatialCql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spatialCql.js","sourceRoot":"","sources":["../../../src/helpers/wfs_engine/spatialCql.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,wCAAwC;AAExC;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,gBAAoC,EAAE,aAA2D;IACxI,IAAI,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,mFAAmF,CAAC,CAAC;IACvG,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,QAAQ,gBAAgB,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,eAAe,CAAC;AAChJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mCAAmC,CAAC,gBAAoC,EAAE,aAAuE;IAC/J,OAAO,cAAc,gBAAgB,CAAC,IAAI,oBAAoB,aAAa,CAAC,GAAG,IAAI,aAAa,CAAC,GAAG,IAAI,CAAC;AAC3G,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,gBAAoC,EAAE,aAAoE;IACpJ,OAAO,WAAW,gBAAgB,CAAC,IAAI,oBAAoB,aAAa,CAAC,GAAG,IAAI,aAAa,CAAC,GAAG,KAAK,aAAa,CAAC,UAAU,UAAU,CAAC;AAC3I,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CAAC,gBAAoC,EAAE,YAAoB;IAC9G,OAAO,cAAc,gBAAgB,CAAC,IAAI,IAAI,YAAY,GAAG,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial input normalization helpers for the structured WFS query compiler.
|
|
3
|
+
*
|
|
4
|
+
* This module turns raw tool input parameters into normalized spatial filter
|
|
5
|
+
* objects that can then be compiled into CQL fragments.
|
|
6
|
+
*/
|
|
7
|
+
import type { GpfWfsGetFeaturesInput, SpatialFilter } from "./schema.js";
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes the raw spatial input into a discriminated spatial filter object.
|
|
10
|
+
*
|
|
11
|
+
* @param input Normalized tool input.
|
|
12
|
+
* @returns A normalized spatial filter, or `undefined` when no spatial filter is requested.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSpatialFilter(input: GpfWfsGetFeaturesInput): SpatialFilter | undefined;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spatial input normalization helpers for the structured WFS query compiler.
|
|
3
|
+
*
|
|
4
|
+
* This module turns raw tool input parameters into normalized spatial filter
|
|
5
|
+
* objects that can then be compiled into CQL fragments.
|
|
6
|
+
*/
|
|
7
|
+
// --- Parameter Groups ---
|
|
8
|
+
const BBOX_PARAM_NAMES = ["bbox_west", "bbox_south", "bbox_east", "bbox_north"];
|
|
9
|
+
const INTERSECTS_POINT_PARAM_NAMES = ["intersects_lon", "intersects_lat"];
|
|
10
|
+
const DWITHIN_PARAM_NAMES = ["dwithin_lon", "dwithin_lat", "dwithin_distance_m"];
|
|
11
|
+
const INTERSECTS_FEATURE_PARAM_NAMES = ["intersects_feature_typename", "intersects_feature_id"];
|
|
12
|
+
// --- Parameter Detection ---
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether any property in a named group is defined on the raw input object.
|
|
15
|
+
*
|
|
16
|
+
* @param input Normalized tool input.
|
|
17
|
+
* @param keys Input keys to inspect.
|
|
18
|
+
* @returns `true` when at least one key from the group is present.
|
|
19
|
+
*/
|
|
20
|
+
function hasAny(input, keys) {
|
|
21
|
+
return keys.some((name) => input[name] !== undefined);
|
|
22
|
+
}
|
|
23
|
+
// --- Per-Mode Readers ---
|
|
24
|
+
/**
|
|
25
|
+
* Reads and validates the `bbox` spatial filter parameters.
|
|
26
|
+
*
|
|
27
|
+
* @param input Normalized tool input.
|
|
28
|
+
* @returns A normalized `bbox` spatial filter.
|
|
29
|
+
*/
|
|
30
|
+
function readBboxFilter(input) {
|
|
31
|
+
if (input.bbox_west === undefined || input.bbox_south === undefined || input.bbox_east === undefined || input.bbox_north === undefined) {
|
|
32
|
+
throw new Error("Le filtre spatial `bbox` exige `bbox_west`, `bbox_south`, `bbox_east` et `bbox_north`.");
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
operator: "bbox",
|
|
36
|
+
west: input.bbox_west,
|
|
37
|
+
south: input.bbox_south,
|
|
38
|
+
east: input.bbox_east,
|
|
39
|
+
north: input.bbox_north,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads and validates the `intersects_point` spatial filter parameters.
|
|
44
|
+
*
|
|
45
|
+
* @param input Normalized tool input.
|
|
46
|
+
* @returns A normalized `intersects_point` spatial filter.
|
|
47
|
+
*/
|
|
48
|
+
function readIntersectsPointFilter(input) {
|
|
49
|
+
if (input.intersects_lon === undefined || input.intersects_lat === undefined) {
|
|
50
|
+
throw new Error("Le filtre spatial `intersects_point` exige `intersects_lon` et `intersects_lat`.");
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
operator: "intersects_point",
|
|
54
|
+
lon: input.intersects_lon,
|
|
55
|
+
lat: input.intersects_lat,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reads and validates the `dwithin_point` spatial filter parameters.
|
|
60
|
+
*
|
|
61
|
+
* @param input Normalized tool input.
|
|
62
|
+
* @returns A normalized `dwithin_point` spatial filter.
|
|
63
|
+
*/
|
|
64
|
+
function readDwithinPointFilter(input) {
|
|
65
|
+
if (input.dwithin_lon === undefined || input.dwithin_lat === undefined || input.dwithin_distance_m === undefined) {
|
|
66
|
+
throw new Error("Le filtre spatial `dwithin_point` exige `dwithin_lon`, `dwithin_lat` et `dwithin_distance_m`.");
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
operator: "dwithin_point",
|
|
70
|
+
lon: input.dwithin_lon,
|
|
71
|
+
lat: input.dwithin_lat,
|
|
72
|
+
distance_m: input.dwithin_distance_m,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reads and validates the `intersects_feature` spatial filter parameters.
|
|
77
|
+
*
|
|
78
|
+
* @param input Normalized tool input.
|
|
79
|
+
* @returns A normalized `intersects_feature` spatial filter.
|
|
80
|
+
*/
|
|
81
|
+
function readIntersectsFeatureFilter(input) {
|
|
82
|
+
if (!input.intersects_feature_typename || !input.intersects_feature_id) {
|
|
83
|
+
throw new Error("Le filtre spatial `intersects_feature` exige `intersects_feature_typename` et `intersects_feature_id`.");
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
operator: "intersects_feature",
|
|
87
|
+
typename: input.intersects_feature_typename,
|
|
88
|
+
feature_id: input.intersects_feature_id,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// --- Public Normalization ---
|
|
92
|
+
/**
|
|
93
|
+
* Normalizes the raw spatial input into a discriminated spatial filter object.
|
|
94
|
+
*
|
|
95
|
+
* @param input Normalized tool input.
|
|
96
|
+
* @returns A normalized spatial filter, or `undefined` when no spatial filter is requested.
|
|
97
|
+
*/
|
|
98
|
+
export function getSpatialFilter(input) {
|
|
99
|
+
const hasBboxParams = hasAny(input, BBOX_PARAM_NAMES);
|
|
100
|
+
const hasIntersectsPointParams = hasAny(input, INTERSECTS_POINT_PARAM_NAMES);
|
|
101
|
+
const hasDwithinParams = hasAny(input, DWITHIN_PARAM_NAMES);
|
|
102
|
+
const hasIntersectsFeatureParams = hasAny(input, INTERSECTS_FEATURE_PARAM_NAMES);
|
|
103
|
+
switch (input.spatial_operator) {
|
|
104
|
+
case undefined:
|
|
105
|
+
if (hasBboxParams || hasIntersectsPointParams || hasDwithinParams || hasIntersectsFeatureParams) {
|
|
106
|
+
throw new Error("Les paramètres spatiaux exigent `spatial_operator`.");
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
case "bbox":
|
|
110
|
+
if (hasIntersectsPointParams || hasDwithinParams || hasIntersectsFeatureParams) {
|
|
111
|
+
throw new Error("Le filtre spatial `bbox` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
112
|
+
}
|
|
113
|
+
return readBboxFilter(input);
|
|
114
|
+
case "intersects_point":
|
|
115
|
+
if (hasBboxParams || hasDwithinParams || hasIntersectsFeatureParams) {
|
|
116
|
+
throw new Error("Le filtre spatial `intersects_point` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
117
|
+
}
|
|
118
|
+
return readIntersectsPointFilter(input);
|
|
119
|
+
case "dwithin_point":
|
|
120
|
+
if (hasBboxParams || hasIntersectsPointParams || hasIntersectsFeatureParams) {
|
|
121
|
+
throw new Error("Le filtre spatial `dwithin_point` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
122
|
+
}
|
|
123
|
+
return readDwithinPointFilter(input);
|
|
124
|
+
case "intersects_feature":
|
|
125
|
+
if (hasBboxParams || hasIntersectsPointParams || hasDwithinParams) {
|
|
126
|
+
throw new Error("Le filtre spatial `intersects_feature` n'accepte pas les paramètres d'un autre mode spatial.");
|
|
127
|
+
}
|
|
128
|
+
return readIntersectsFeatureFilter(input);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=spatialFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spatialFilter.js","sourceRoot":"","sources":["../../../src/helpers/wfs_engine/spatialFilter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,2BAA2B;AAE3B,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAU,CAAC;AACzF,MAAM,4BAA4B,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAU,CAAC;AACnF,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,oBAAoB,CAAU,CAAC;AAC1F,MAAM,8BAA8B,GAAG,CAAC,6BAA6B,EAAE,uBAAuB,CAAU,CAAC;AAEzG,8BAA8B;AAE9B;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,KAA6B,EAAE,IAAuB;IACpE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAoC,CAAC,KAAK,SAAS,CAAC,CAAC;AACxF,CAAC;AAED,2BAA2B;AAE3B;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAA6B;IACnD,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,I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