mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-25 01:22:47 +00:00
a71f3b2d83
git-svn-id: http://svn.osgeo.org/postgis/trunk@4551 b70326c6-7e19-0410-871a-916f4a2858ee
69 lines
2.3 KiB
C
69 lines
2.3 KiB
C
/**********************************************************************
|
|
* $Id: lwgeodetic.c 4494 2009-09-14 10:54:33Z mcayland $
|
|
*
|
|
* PostGIS - Spatial Types for PostgreSQL
|
|
* Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
|
|
*
|
|
* This is free software; you can redistribute and/or modify it under
|
|
* the terms of the GNU General Public Licence. See the COPYING file.
|
|
*
|
|
**********************************************************************/
|
|
|
|
#include <math.h>
|
|
#include "libgeom.h"
|
|
|
|
extern int gbox_geocentric_slow;
|
|
|
|
/**
|
|
* Point in spherical coordinates on the world. Units of radians.
|
|
*/
|
|
typedef struct {
|
|
double lon;
|
|
double lat;
|
|
} GEOGRAPHIC_POINT;
|
|
|
|
/**
|
|
* Two-point great circle segment from a to b.
|
|
*/
|
|
typedef struct {
|
|
GEOGRAPHIC_POINT start;
|
|
GEOGRAPHIC_POINT end;
|
|
} GEOGRAPHIC_EDGE;
|
|
|
|
/**
|
|
* Conversion functions
|
|
*/
|
|
#define deg2rad(d) (PI * (d) / 180.0)
|
|
#define rad2deg(r) (180.0 * (r) / PI)
|
|
|
|
/**
|
|
* Ape a java function
|
|
*/
|
|
#define signum(a) ((a) < 0 ? -1 : ((a) > 0 ? 1 : (a)))
|
|
|
|
/*
|
|
** Prototypes for internal functions.
|
|
*/
|
|
void geog2cart(GEOGRAPHIC_POINT g, POINT3D *p);
|
|
void cart2geog(POINT3D p, GEOGRAPHIC_POINT *g);
|
|
void robust_cross_product(GEOGRAPHIC_POINT p, GEOGRAPHIC_POINT q, POINT3D *a);
|
|
void x_to_z(POINT3D *p);
|
|
void y_to_z(POINT3D *p);
|
|
int edge_point_on_plane(GEOGRAPHIC_EDGE e, GEOGRAPHIC_POINT p);
|
|
int edge_point_in_cone(GEOGRAPHIC_EDGE e, GEOGRAPHIC_POINT p);
|
|
int edge_contains_longitude(GEOGRAPHIC_EDGE e, GEOGRAPHIC_POINT p);
|
|
int edge_contains_point(GEOGRAPHIC_EDGE e, GEOGRAPHIC_POINT p);
|
|
double z_to_latitude(double z, int top);
|
|
int clairaut_cartesian(POINT3D start, POINT3D end, GEOGRAPHIC_POINT *g_top, GEOGRAPHIC_POINT *g_bottom);
|
|
int clairaut_geographic(GEOGRAPHIC_POINT start, GEOGRAPHIC_POINT end, GEOGRAPHIC_POINT *g_top, GEOGRAPHIC_POINT *g_bottom);
|
|
double sphere_distance(GEOGRAPHIC_POINT s, GEOGRAPHIC_POINT e);
|
|
double sphere_direction(GEOGRAPHIC_POINT s, GEOGRAPHIC_POINT e);
|
|
int sphere_project(GEOGRAPHIC_POINT r, double distance, double azimuth, GEOGRAPHIC_POINT *n);
|
|
int edge_calculate_gbox(GEOGRAPHIC_EDGE e, GBOX *gbox);
|
|
int edge_calculate_gbox_slow(GEOGRAPHIC_EDGE e, GBOX *gbox);
|
|
int edge_intersection(GEOGRAPHIC_EDGE e1, GEOGRAPHIC_EDGE e2, GEOGRAPHIC_POINT *g);
|
|
void edge_deg2rad(GEOGRAPHIC_EDGE *e);
|
|
void edge_rad2deg(GEOGRAPHIC_EDGE *e);
|
|
void point_deg2rad(GEOGRAPHIC_POINT *p);
|
|
void point_rad2deg(GEOGRAPHIC_POINT *p);
|