1#ifndef SQL_GIS_FUNCTOR_H_INCLUDED
2#define SQL_GIS_FUNCTOR_H_INCLUDED
106 std::stringstream ss;
171 template <
typename F>
176 switch (g1->
type()) {
178 switch (g2->
type()) {
180 return f.eval(down_cast<const Cartesian_point *>(g1),
181 down_cast<const Cartesian_point *>(g2));
183 return f.eval(down_cast<const Cartesian_point *>(g1),
184 down_cast<const Cartesian_linestring *>(g2));
186 return f.eval(down_cast<const Cartesian_point *>(g1),
187 down_cast<const Cartesian_polygon *>(g2));
190 down_cast<const Cartesian_point *>(g1),
191 down_cast<const Cartesian_geometrycollection *>(g2));
193 return f.eval(down_cast<const Cartesian_point *>(g1),
194 down_cast<const Cartesian_multipoint *>(g2));
196 return f.eval(down_cast<const Cartesian_point *>(g1),
197 down_cast<const Cartesian_multilinestring *>(g2));
199 return f.eval(down_cast<const Cartesian_point *>(g1),
200 down_cast<const Cartesian_multipolygon *>(g2));
206 switch (g2->
type()) {
208 return f.eval(down_cast<const Cartesian_linestring *>(g1),
209 down_cast<const Cartesian_point *>(g2));
211 return f.eval(down_cast<const Cartesian_linestring *>(g1),
212 down_cast<const Cartesian_linestring *>(g2));
214 return f.eval(down_cast<const Cartesian_linestring *>(g1),
215 down_cast<const Cartesian_polygon *>(g2));
218 down_cast<const Cartesian_linestring *>(g1),
219 down_cast<const Cartesian_geometrycollection *>(g2));
221 return f.eval(down_cast<const Cartesian_linestring *>(g1),
222 down_cast<const Cartesian_multipoint *>(g2));
224 return f.eval(down_cast<const Cartesian_linestring *>(g1),
225 down_cast<const Cartesian_multilinestring *>(g2));
227 return f.eval(down_cast<const Cartesian_linestring *>(g1),
228 down_cast<const Cartesian_multipolygon *>(g2));
234 switch (g2->
type()) {
236 return f.eval(down_cast<const Cartesian_polygon *>(g1),
237 down_cast<const Cartesian_point *>(g2));
239 return f.eval(down_cast<const Cartesian_polygon *>(g1),
240 down_cast<const Cartesian_linestring *>(g2));
242 return f.eval(down_cast<const Cartesian_polygon *>(g1),
243 down_cast<const Cartesian_polygon *>(g2));
246 down_cast<const Cartesian_polygon *>(g1),
247 down_cast<const Cartesian_geometrycollection *>(g2));
249 return f.eval(down_cast<const Cartesian_polygon *>(g1),
250 down_cast<const Cartesian_multipoint *>(g2));
252 return f.eval(down_cast<const Cartesian_polygon *>(g1),
253 down_cast<const Cartesian_multilinestring *>(g2));
255 return f.eval(down_cast<const Cartesian_polygon *>(g1),
256 down_cast<const Cartesian_multipolygon *>(g2));
262 switch (g2->
type()) {
265 down_cast<const Cartesian_geometrycollection *>(g1),
266 down_cast<const Cartesian_point *>(g2));
269 down_cast<const Cartesian_geometrycollection *>(g1),
270 down_cast<const Cartesian_linestring *>(g2));
273 down_cast<const Cartesian_geometrycollection *>(g1),
274 down_cast<const Cartesian_polygon *>(g2));
277 down_cast<const Cartesian_geometrycollection *>(g1),
278 down_cast<const Cartesian_geometrycollection *>(g2));
281 down_cast<const Cartesian_geometrycollection *>(g1),
282 down_cast<const Cartesian_multipoint *>(g2));
285 down_cast<const Cartesian_geometrycollection *>(g1),
286 down_cast<const Cartesian_multilinestring *>(g2));
289 down_cast<const Cartesian_geometrycollection *>(g1),
290 down_cast<const Cartesian_multipolygon *>(g2));
296 switch (g2->
type()) {
298 return f.eval(down_cast<const Cartesian_multipoint *>(g1),
299 down_cast<const Cartesian_point *>(g2));
301 return f.eval(down_cast<const Cartesian_multipoint *>(g1),
302 down_cast<const Cartesian_linestring *>(g2));
304 return f.eval(down_cast<const Cartesian_multipoint *>(g1),
305 down_cast<const Cartesian_polygon *>(g2));
308 down_cast<const Cartesian_multipoint *>(g1),
309 down_cast<const Cartesian_geometrycollection *>(g2));
311 return f.eval(down_cast<const Cartesian_multipoint *>(g1),
312 down_cast<const Cartesian_multipoint *>(g2));
314 return f.eval(down_cast<const Cartesian_multipoint *>(g1),
315 down_cast<const Cartesian_multilinestring *>(g2));
317 return f.eval(down_cast<const Cartesian_multipoint *>(g1),
318 down_cast<const Cartesian_multipolygon *>(g2));
324 switch (g2->
type()) {
326 return f.eval(down_cast<const Cartesian_multilinestring *>(g1),
327 down_cast<const Cartesian_point *>(g2));
329 return f.eval(down_cast<const Cartesian_multilinestring *>(g1),
330 down_cast<const Cartesian_linestring *>(g2));
332 return f.eval(down_cast<const Cartesian_multilinestring *>(g1),
333 down_cast<const Cartesian_polygon *>(g2));
336 down_cast<const Cartesian_multilinestring *>(g1),
337 down_cast<const Cartesian_geometrycollection *>(g2));
339 return f.eval(down_cast<const Cartesian_multilinestring *>(g1),
340 down_cast<const Cartesian_multipoint *>(g2));
342 return f.eval(down_cast<const Cartesian_multilinestring *>(g1),
343 down_cast<const Cartesian_multilinestring *>(g2));
345 return f.eval(down_cast<const Cartesian_multilinestring *>(g1),
346 down_cast<const Cartesian_multipolygon *>(g2));
352 switch (g2->
type()) {
354 return f.eval(down_cast<const Cartesian_multipolygon *>(g1),
355 down_cast<const Cartesian_point *>(g2));
357 return f.eval(down_cast<const Cartesian_multipolygon *>(g1),
358 down_cast<const Cartesian_linestring *>(g2));
360 return f.eval(down_cast<const Cartesian_multipolygon *>(g1),
361 down_cast<const Cartesian_polygon *>(g2));
364 down_cast<const Cartesian_multipolygon *>(g1),
365 down_cast<const Cartesian_geometrycollection *>(g2));
367 return f.eval(down_cast<const Cartesian_multipolygon *>(g1),
368 down_cast<const Cartesian_multipoint *>(g2));
370 return f.eval(down_cast<const Cartesian_multipolygon *>(g1),
371 down_cast<const Cartesian_multilinestring *>(g2));
373 return f.eval(down_cast<const Cartesian_multipolygon *>(g1),
374 down_cast<const Cartesian_multipolygon *>(g2));
384 switch (g1->
type()) {
386 switch (g2->
type()) {
388 return f.eval(down_cast<const Geographic_point *>(g1),
389 down_cast<const Geographic_point *>(g2));
391 return f.eval(down_cast<const Geographic_point *>(g1),
392 down_cast<const Geographic_linestring *>(g2));
394 return f.eval(down_cast<const Geographic_point *>(g1),
395 down_cast<const Geographic_polygon *>(g2));
398 down_cast<const Geographic_point *>(g1),
399 down_cast<const Geographic_geometrycollection *>(g2));
401 return f.eval(down_cast<const Geographic_point *>(g1),
402 down_cast<const Geographic_multipoint *>(g2));
405 down_cast<const Geographic_point *>(g1),
406 down_cast<const Geographic_multilinestring *>(g2));
408 return f.eval(down_cast<const Geographic_point *>(g1),
409 down_cast<const Geographic_multipolygon *>(g2));
415 switch (g2->
type()) {
417 return f.eval(down_cast<const Geographic_linestring *>(g1),
418 down_cast<const Geographic_point *>(g2));
420 return f.eval(down_cast<const Geographic_linestring *>(g1),
421 down_cast<const Geographic_linestring *>(g2));
423 return f.eval(down_cast<const Geographic_linestring *>(g1),
424 down_cast<const Geographic_polygon *>(g2));
427 down_cast<const Geographic_linestring *>(g1),
428 down_cast<const Geographic_geometrycollection *>(g2));
430 return f.eval(down_cast<const Geographic_linestring *>(g1),
431 down_cast<const Geographic_multipoint *>(g2));
434 down_cast<const Geographic_linestring *>(g1),
435 down_cast<const Geographic_multilinestring *>(g2));
437 return f.eval(down_cast<const Geographic_linestring *>(g1),
438 down_cast<const Geographic_multipolygon *>(g2));
444 switch (g2->
type()) {
446 return f.eval(down_cast<const Geographic_polygon *>(g1),
447 down_cast<const Geographic_point *>(g2));
449 return f.eval(down_cast<const Geographic_polygon *>(g1),
450 down_cast<const Geographic_linestring *>(g2));
452 return f.eval(down_cast<const Geographic_polygon *>(g1),
453 down_cast<const Geographic_polygon *>(g2));
456 down_cast<const Geographic_polygon *>(g1),
457 down_cast<const Geographic_geometrycollection *>(g2));
459 return f.eval(down_cast<const Geographic_polygon *>(g1),
460 down_cast<const Geographic_multipoint *>(g2));
463 down_cast<const Geographic_polygon *>(g1),
464 down_cast<const Geographic_multilinestring *>(g2));
466 return f.eval(down_cast<const Geographic_polygon *>(g1),
467 down_cast<const Geographic_multipolygon *>(g2));
473 switch (g2->
type()) {
476 down_cast<const Geographic_geometrycollection *>(g1),
477 down_cast<const Geographic_point *>(g2));
480 down_cast<const Geographic_geometrycollection *>(g1),
481 down_cast<const Geographic_linestring *>(g2));
484 down_cast<const Geographic_geometrycollection *>(g1),
485 down_cast<const Geographic_polygon *>(g2));
488 down_cast<const Geographic_geometrycollection *>(g1),
489 down_cast<const Geographic_geometrycollection *>(g2));
492 down_cast<const Geographic_geometrycollection *>(g1),
493 down_cast<const Geographic_multipoint *>(g2));
496 down_cast<const Geographic_geometrycollection *>(g1),
497 down_cast<const Geographic_multilinestring *>(g2));
500 down_cast<const Geographic_geometrycollection *>(g1),
501 down_cast<const Geographic_multipolygon *>(g2));
507 switch (g2->
type()) {
509 return f.eval(down_cast<const Geographic_multipoint *>(g1),
510 down_cast<const Geographic_point *>(g2));
512 return f.eval(down_cast<const Geographic_multipoint *>(g1),
513 down_cast<const Geographic_linestring *>(g2));
515 return f.eval(down_cast<const Geographic_multipoint *>(g1),
516 down_cast<const Geographic_polygon *>(g2));
519 down_cast<const Geographic_multipoint *>(g1),
520 down_cast<const Geographic_geometrycollection *>(g2));
522 return f.eval(down_cast<const Geographic_multipoint *>(g1),
523 down_cast<const Geographic_multipoint *>(g2));
526 down_cast<const Geographic_multipoint *>(g1),
527 down_cast<const Geographic_multilinestring *>(g2));
529 return f.eval(down_cast<const Geographic_multipoint *>(g1),
530 down_cast<const Geographic_multipolygon *>(g2));
536 switch (g2->
type()) {
538 return f.eval(down_cast<const Geographic_multilinestring *>(g1),
539 down_cast<const Geographic_point *>(g2));
541 return f.eval(down_cast<const Geographic_multilinestring *>(g1),
542 down_cast<const Geographic_linestring *>(g2));
544 return f.eval(down_cast<const Geographic_multilinestring *>(g1),
545 down_cast<const Geographic_polygon *>(g2));
548 down_cast<const Geographic_multilinestring *>(g1),
549 down_cast<const Geographic_geometrycollection *>(g2));
551 return f.eval(down_cast<const Geographic_multilinestring *>(g1),
552 down_cast<const Geographic_multipoint *>(g2));
555 down_cast<const Geographic_multilinestring *>(g1),
556 down_cast<const Geographic_multilinestring *>(g2));
558 return f.eval(down_cast<const Geographic_multilinestring *>(g1),
559 down_cast<const Geographic_multipolygon *>(g2));
565 switch (g2->
type()) {
567 return f.eval(down_cast<const Geographic_multipolygon *>(g1),
568 down_cast<const Geographic_point *>(g2));
570 return f.eval(down_cast<const Geographic_multipolygon *>(g1),
571 down_cast<const Geographic_linestring *>(g2));
573 return f.eval(down_cast<const Geographic_multipolygon *>(g1),
574 down_cast<const Geographic_polygon *>(g2));
577 down_cast<const Geographic_multipolygon *>(g1),
578 down_cast<const Geographic_geometrycollection *>(g2));
580 return f.eval(down_cast<const Geographic_multipolygon *>(g1),
581 down_cast<const Geographic_multipoint *>(g2));
584 down_cast<const Geographic_multipolygon *>(g1),
585 down_cast<const Geographic_multilinestring *>(g2));
587 return f.eval(down_cast<const Geographic_multipolygon *>(g1),
588 down_cast<const Geographic_multipolygon *>(g2));
627 return f.eval(down_cast<const Cartesian_point &>(g));
629 return f.eval(down_cast<const Cartesian_linestring &>(g));
631 return f.eval(down_cast<const Cartesian_polygon &>(g));
633 return f.eval(down_cast<const Cartesian_geometrycollection &>(g));
635 return f.eval(down_cast<const Cartesian_multipoint &>(g));
637 return f.eval(down_cast<const Cartesian_multilinestring &>(g));
639 return f.eval(down_cast<const Cartesian_multipolygon &>(g));
650 return f.eval(down_cast<const Geographic_point &>(g));
652 return f.eval(down_cast<const Geographic_linestring &>(g));
654 return f.eval(down_cast<const Geographic_polygon &>(g));
656 return f.eval(down_cast<const Geographic_geometrycollection &>(g));
658 return f.eval(down_cast<const Geographic_multipoint &>(g));
660 return f.eval(down_cast<const Geographic_multilinestring &>(g));
662 return f.eval(down_cast<const Geographic_multipolygon &>(g));
The base class of all functors that takes two geometry arguments.
Definition: functor.h:165
virtual T operator()(const Geometry *g1, const Geometry *g2) const =0
virtual ~Functor()=default
static T apply(F &f, const Geometry *g1, const Geometry *g2)
Definition: functor.h:172
Abstract superclass for all geometric objects.
Definition: geometries.h:100
virtual Coordinate_system coordinate_system() const =0
Gets the coordinate system.
virtual Geometry_type type() const =0
Gets the geometry type of the object.
The base class of all functors that take one geometry argument.
Definition: functor.h:615
virtual T operator()(const Geometry &) const =0
virtual ~Unary_functor()=default
static T apply(F &f, const Geometry &g)
Definition: functor.h:622
Function/parameter combination not implemented exception.
Definition: functor.h:88
Srs_type
Definition: functor.h:90
@ kCartesian
Definition: functor.h:90
@ kProjected
Definition: functor.h:90
@ kGeographic
Definition: functor.h:90
const char * typenames() const
Definition: functor.h:113
Srs_type m_srs_type
Definition: functor.h:93
std::string m_typenames
Definition: functor.h:95
static not_implemented_exception for_projected(const Geometry &g1, const Geometry &g2)
Definition: functor.h:119
Srs_type srs_type() const
Definition: functor.h:112
static not_implemented_exception for_non_projected(const Geometry &g)
Definition: functor.h:124
not_implemented_exception(Srs_type srs_type, const Geometry &g1, const Geometry &g2)
Definition: functor.h:102
static not_implemented_exception for_non_projected(const Geometry &g1, const Geometry &g2)
Definition: functor.h:135
static not_implemented_exception for_projected(const Geometry &g)
Definition: functor.h:115
not_implemented_exception(Srs_type srs_type, const Geometry &g)
Definition: functor.h:97
NULL value exception.
Definition: functor.h:152
This file declares the geometry class hierarchy used by the server as the internal representation of ...
This file declares the coordinate system specific subclasses of the geometry class hierarchy.
@ kCartesian
A Cartesian plane with the same unit in both directions.
@ kGeographic
An ellipsoidal system with longitude and latitude coordinates, both in the same unit.
const char * type_to_name(Geometry_type type)
Get the type name string corresponding to a geometry type.
Definition: geometries.cc:688
Latitude out of range exception.
Definition: functor.h:70
double range_min
Definition: functor.h:72
double range_max
Definition: functor.h:73
latitude_out_of_range_exception(double value, double range_min, double range_max)
Definition: functor.h:75
double value
Definition: functor.h:71
Longitude out of range exception.
Definition: functor.h:56
longitude_out_of_range_exception(double value, double range_min, double range_max)
Definition: functor.h:61
double value
Definition: functor.h:57
double range_min
Definition: functor.h:58
double range_max
Definition: functor.h:59