/**
* Returns a new bytebuffer were both ingoing bytebuffers is merged.
-* Caller is responsible for freeing both incoming bytefyffers and resulting bytebuffer
+* Caller is responsible for freeing both incoming bytebuffers and resulting bytebuffer
*/
bytebuffer_t*
bytebuffer_merge(bytebuffer_t **buff_array, int nbuffers)
/**
-We create the minheap by ordering the minheap array by the areas in the areanode structs that the minheap keys refere to
+We create the minheap by ordering the minheap array by the areas in the areanode structs that the minheap keys refer to
*/
static int cmpfunc (const void * a, const void * b)
{
double v1 = (*(areanode**)a)->area;
double v2 = (*(areanode**)b)->area;
- /*qsort gives unpredictable results when comaping identical values.
- If two values is the same we force returning the last point in hte point array.
- That way we get the same ordering on diffreent machines and pllatforms*/
+ /*qsort gives unpredictable results when comparing identical values.
+ If two values is the same we force returning the last point in the point array.
+ That way we get the same ordering on different machines and platforms*/
if (v1==v2)
return (*(areanode**)a)-(*(areanode**)b);
else
check_order_min_area=ea->res_arealist[current];
- /*The found smallest area point is now regarded as elimnated and we have to recalculate the area the adjacent (ignoring earlier elimnated points) points gives*/
+ /*The found smallest area point is now regarded as eliminated and we have to recalculate the area the adjacent (ignoring earlier eliminated points) points gives*/
/*FInd point before and after*/
before_current=ea->initial_arealist[current].prev;
ea->initial_arealist[before_current].next = ea->initial_arealist[current].next;
ea->initial_arealist[after_current].prev = ea->initial_arealist[current].prev;
- /*Check if we are finnished*/
+ /*Check if we are finished*/
if((!set_area && ea->res_arealist[current]>trshld) || (ea->initial_arealist[0].next==(npoints-1)))
go_on=0;
if(set_area)
{
- /*Only return points with an effective area above the threashold*/
+ /*Only return points with an effective area above the threshold*/
for (p=0;p<ea->inpts->npoints;p++)
{
if(ea->res_arealist[p]>trshld)
}
else
{
- /*Only return points with an effective area above the threashold*/
+ /*Only return points with an effective area above the threshold*/
for (p=0;p<ea->inpts->npoints;p++)
{
if(ea->res_arealist[p]>trshld)
if( lwpoly_add_ring(opoly,pa ) == LW_FAILURE )
return NULL;
}
- /*Inner rings we allow to ocollapse and then we remove them*/
+ /*Inner rings we allow to collapse and then we remove them*/
avoid_collapse=0;
}
/**
This structure is placed in an array with one member per point.
-It has links into the minheap rtee and kepps track of eliminated points
+It has links into the minheap rtee and keeps track of eliminated points
*/
typedef struct
{
/**
This structure holds a minheap tree that is used to keep track of what points that has the smallest effective area.
-When elliminating points the neighbor points has its effective area affected and the minheap helps to resort efficient.
+When eliminating points the neighbor points has its effective area affected and the minheap helps to resort efficient.
*/
typedef struct
{
/**
-Structure to hold pointarray and it's arealist
+Structure to hold pointarray and its arealist
*/
typedef struct
{
radius_A = lw_arc_center(A1, A2, A3, &C);
- /* Negative radius signals straight line, p1/p2/p3 are colinear */
+ /* Negative radius signals straight line, p1/p2/p3 are collinear */
if (radius_A < 0.0)
{
gbox->xmin = FP_MIN(A1->x, A3->x);
/* Unfortunately including advanced instructions is something that
only helps a small sliver of users who can build their own
knowing the target system they will be running on. Packagers
-have to aim for the lowest common demoninator. So this is
+have to aim for the lowest common denominator. So this is
dead code for the forseeable future. */
#define HAVE_PDEP 0
#if HAVE_PDEP
/******************************************************************
* GBOX structure.
-* We include the flags (information about dimensinality),
+* We include the flags (information about dimensionality),
* so we don't have to constantly pass them
* into functions that use the GBOX.
*/
*/
typedef struct
{
- /* Array of POINT 2D, 3D or 4D, possibly missaligned. */
+ /* Array of POINT 2D, 3D or 4D, possibly misaligned. */
uint8_t *serialized_pointlist;
/* Use FLAGS_* macros to handle */
*/
/**
- * @param minpts minimun number of points to retain, if possible.
+ * @param minpts minimum number of points to retain, if possible.
*/
void ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, uint32_t minpts);
* @param fields fields to be filled in the returned structure, see
* LWT_COL_EDGE_* macros
* @param limit max number of edges to return, 0 for no limit, -1
- * to only check for existance if a matching row.
+ * to only check for existence if a matching row.
*
* @return an array of edges or null in the following cases:
* - limit=-1 ("numelems" is set to 1 if found, 0 otherwise)
* @param fields fields to be filled in the returned structure, see
* LWT_COL_NODE_* macros
* @param limit max number of nodes to return, 0 for no limit, -1
- * to only check for existance if a matching row.
+ * to only check for existence if a matching row.
*
* @return an array of nodes or null in the following cases:
* - limit=-1 ("numelems" is set to 1 if found, 0 otherwise)
* @param fields fields to be filled in the returned structure, see
* LWT_COL_EDGE_* macros
* @param limit max number of edges to return, 0 for no limit, -1
- * to only check for existance if a matching row.
+ * to only check for existence if a matching row.
*
* @return an array of edges or null in the following cases:
* - limit=-1 ("numelems" is set to 1 if found, 0 otherwise)
* @param upd_fields fields to be updated for the selected nodes,
* see LWT_COL_NODE_* macros
* @param exc_node an LWT_ISO_NODE object with exclusion fields set,
- * can be NULL if no exlusion condition exists.
+ * can be NULL if no exclusion condition exists.
* @param exc_fields fields used for excluding nodes from the update,
* see LWT_COL_NODE_* macros
*
*
* @return an array of signed edge identifiers (positive edges being
* walked in their direction, negative ones in opposite) or
- * NULL on error (@see lastErroMessage)
+ * NULL on error (@see lastErrorMessage)
*/
LWT_ELEMID* (*getRingEdges) (
const LWT_BE_TOPOLOGY* topo,
* see LWT_COL_EDGE_* macros
*
* @return number of edges being updated or -1 on error
- * (@see lastErroMessage)
+ * (@see lastErrorMessage)
*/
int (*updateEdgesById) (
const LWT_BE_TOPOLOGY* topo,
* see LWT_COL_NODE_* macros
*
* @return number of nodes being updated or -1 on error
- * (@see lastErroMessage)
+ * (@see lastErrorMessage)
*/
int (*updateNodesById) (
const LWT_BE_TOPOLOGY* topo,
* @param numelems number of face identifiers in the ids array
*
* @return number of faces being deleted or -1 on error
- * (@see lastErroMessage)
+ * (@see lastErrorMessage)
*/
int (*deleteFacesById) (
const LWT_BE_TOPOLOGY* topo,
* @param numelems number of node identifiers in the ids array
*
* @return number of nodes being deleted or -1 on error
- * (@see lastErroMessage)
+ * (@see lastErrorMessage)
*/
int (*deleteNodesById) (
const LWT_BE_TOPOLOGY* topo,
* @param pt the node position
* @param skipChecks if non-zero skips consistency checks
* (coincident nodes, crossing edges,
- * actual face containement)
+ * actual face containment)
*
* @return ID of the newly added node, or -1 on error
* (liblwgeom error handler will be invoked with error message)
*
* For ST_AddEdgeModFace
*
- * If the new edge splits a face, the face is shrinked and a new one
+ * If the new edge splits a face, the face is shrunk and a new one
* is created. Unless the face being split is the Universal Face, the
* new face will be on the right side of the newly added edge.
*
* @param geom the edge geometry
* @param skipChecks if non-zero skips consistency checks
* (curve being simple and valid, start/end nodes
- * consistency actual face containement)
+ * consistency actual face containment)
*
* @return ID of the newly added edge or null on error
* (liblwgeom error handler will be invoked with error message)
* @param geom the edge geometry
* @param skipChecks if non-zero skips consistency checks
* (curve being simple and valid, start/end nodes
- * consistency actual face containement)
+ * consistency actual face containment)
* @return ID of the newly added edge
*
*/
/**
* Determines the center of the circle defined by the three given points.
* In the event the circle is complete, the midpoint of the segment defined
-* by the first and second points is returned. If the points are colinear,
+* by the first and second points is returned. If the points are collinear,
* as determined by equal slopes, then NULL is returned. If the interior
-* point is coincident with either end point, they are taken as colinear.
+* point is coincident with either end point, they are taken as collinear.
*/
double
lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
/*
** Crossing at a co-linearity can be turned handled by extending
- ** segment to next vertext and seeing if the end points straddle
+ ** segment to next vertex and seeing if the end points straddle
** the co-linear segment.
*/
if ( this_cross == SEG_COLINEAR )
}
/**
-* Convert spherical coordinates to cartesion coordinates on unit sphere
+* Convert spherical coordinates to cartesian coordinates on unit sphere
*/
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
{
}
/**
-* Convert cartesion coordinates on unit sphere to spherical coordinates
+* Convert cartesian coordinates on unit sphere to spherical coordinates
*/
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
{
}
/**
-* Convert lon/lat coordinates to cartesion coordinates on unit sphere
+* Convert lon/lat coordinates to cartesian coordinates on unit sphere
*/
void ll2cart(const POINT2D *g, POINT3D *p)
{
}
/**
-* Convert cartesion coordinates on unit sphere to lon/lat coordinates
+* Convert cartesian coordinates on unit sphere to lon/lat coordinates
static void cart2ll(const POINT3D *p, POINT2D *g)
{
g->x = longitude_degrees_normalize(180.0 * atan2(p->y, p->x) / M_PI);
#if 0 /* unused */
/**
* Computes the spherical excess of a spherical triangle defined by
-* the three vectices A, B, C. Computes on the unit sphere (i.e., divides
+* the three vertices A, B, C. Computes on the unit sphere (i.e., divides
* edge lengths by the radius, even if the radius is 1.0). The excess is
* signed based on the sign of the delta longitude of A and B.
*
/**
* Computes the pole of the great circle disk which is the intersection of
-* the great circle with the line of maximum/minimum gradiant that lies on
+* the great circle with the line of maximum/minimum gradient that lies on
* the great circle plane.
*/
int clairaut_cartesian(const POINT3D *start, const POINT3D *end, GEOGRAPHIC_POINT *g_top, GEOGRAPHIC_POINT *g_bottom)
/**
* Computes the pole of the great circle disk which is the intersection of
-* the great circle with the line of maximum/minimum gradiant that lies on
+* the great circle with the line of maximum/minimum gradient that lies on
* the great circle plane.
*/
int clairaut_geographic(const GEOGRAPHIC_POINT *start, const GEOGRAPHIC_POINT *end, GEOGRAPHIC_POINT *g_top, GEOGRAPHIC_POINT *g_bottom)
LWDEBUGF(4, "parallel edges found! dot_product = %.12g", dot_product(&ea, &eb));
/* Parallel (maybe equal) edges! */
/* Hack alert, only returning ONE end of the edge right now, most do better later. */
- /* Hack alart #2, returning a value of 2 to indicate a co-linear crossing event. */
+ /* Hack alert #2, returning a value of 2 to indicate a co-linear crossing event. */
if ( edge_contains_point(e1, &(e2->start)) )
{
*g = e2->start;
static int ptarray_segmentize_sphere_edge_recursive (
- const POINT3D *p1, const POINT3D *p2, /* 3-space points we are interpolating beween */
+ const POINT3D *p1, const POINT3D *p2, /* 3-space points we are interpolating between */
const POINT4D *v1, const POINT4D *v2, /* real values and z/m values */
double d, double max_seg_length, /* current segment length and segment limit */
POINTARRAY *pa) /* write out results here */
/**
* Calculate the distance between two LWGEOMs, using the coordinates are
-* longitude and latitude. Return immediately when the calulated distance drops
+* longitude and latitude. Return immediately when the calculated distance drops
* below the tolerance (useful for dwithin calculations).
* Return a negative distance for incalculable cases.
*/
return LW_FALSE;
}
- /* no abort condition found, so the poly2 should be completly inside poly1 */
+ /* no abort condition found, so the poly2 should be completely inside poly1 */
return LW_TRUE;
}
/**
* Checks if any edges of lwpoly intersect with the line formed by the pointarray
- * return LW_TRUE if any intersection beetween the given polygon and the line
+ * return LW_TRUE if any intersection between the given polygon and the line
*/
int lwpoly_intersects_line(const LWPOLY* lwpoly, const POINTARRAY* line)
{
LWDEBUGF(3," offset1 is %g", offset1);
/* Sometimes the sphere_direction function fails... this causes the center calculation */
- /* to fail too. In that case, we're going to fall back ot a cartesian calculation, which */
+ /* to fail too. In that case, we're going to fall back to a cartesian calculation, which */
/* is less exact, so we also have to pad the radius by (hack alert) an arbitrary amount */
/* which is hopefully always big enough to contain the input edges */
if ( circ_center_spherical(&c1, &(c[i]->center), dist, offset1, &new_center) == LW_FAILURE )
lwfree(nodes);
}
- /* Metatdata about polygons, we need this to apply P-i-P tests */
+ /* Metadata about polygons, we need this to apply P-i-P tests */
/* selectively when doing distance calculations */
node->geom_type = lwgeom_get_type((LWGEOM*)lwpoly);
lwpoly_pt_outside(lwpoly, &(node->pt_outside));
/**
-* Calculate the gbox for this goemetry, a cartesian box or
+* Calculate the gbox for this geometry, a cartesian box or
* geodetic box, depending on how it is flagged.
*/
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
}
/*
- * Returns the float thats very close to the input, but >=.
+ * Returns the float that's very close to the input, but >=.
* handles the funny differences in float4 and float8 reps.
*/
inline float
/*
* Return Nth vertex in GEOSGeometry as a POINT.
- * May return NULL if the geometry has NO vertexex.
+ * May return NULL if the geometry has NO vertex.
*/
GEOSGeometry* LWGEOM_GEOS_getPointN(const GEOSGeometry*, uint32_t);
GEOSGeometry*
}
/* NOTE: the noding process may drop lines collapsing to points.
- * We want to retrive any of those */
+ * We want to retrieve any of those */
{
GEOSGeometry* pi;
GEOSGeometry* po;
* Return a PostGIS pointarray from a simple SFCGAL geometry:
* POINT, LINESTRING or TRIANGLE
*
- * Trought an error on others types
+ * Throw an error on others types
*/
static POINTARRAY*
ptarray_from_SFCGAL(const sfcgal_geometry_t* geom, int want3d)
LWDEBUGF(1, "edge's end node is %g,%g", p2.x, p2.y);
/*
- * Check endpoints existance, match with Curve geometry
+ * Check endpoints existence, match with Curve geometry
* and get face information (if any)
*/
/*
-- Update faces MBR of left and right faces
-- TODO: think about ways to optimize this part, like see if
- -- the old edge geometry partecipated in the definition
+ -- the old edge geometry participated in the definition
-- of the current MBR (for shrinking) or the new edge MBR
-- would be larger than the old face MBR...
--
if (l < (patch->nrings - 1) )
{
/** @todo TODO: Decide the best way to render holes
- * Evidentally according to my X3D expert the X3D consortium doesn't really
+ * Evidently according to my X3D expert the X3D consortium doesn't really
* support holes and it's an issue of argument among many that feel it should. He thinks CAD x3d extensions to spec might.
* What he has done and others developing X3D exports to simulate a hole is to cut around it.
* So if you have a donut, you would cut it into half and have 2 solid polygons. Not really sure the best way to handle this.
/* If surface is less than 4 faces hard to be closed too */
if (psurface->ngeoms < 4) return 0;
- /* Max theorical arcs number if no one is shared ... */
+ /* Max theoretical arcs number if no one is shared ... */
for (i=0, narcs=0 ; i < psurface->ngeoms ; i++)
{
patch = (LWPOLY *) psurface->geoms[i];
if ( angle < 0 ) angle = 2 * M_PI + angle;
num_quadrants = ( 4 * angle ) / ( 2 * M_PI );
- LWDEBUGF(4, "arc angle (%g %g, %g %g, %g %g) is %g (side is %d), quandrants:%g", first.x, first.y, center.x, center.y, b.x, b.y, angle, p2_side, num_quadrants);
+ LWDEBUGF(4, "arc angle (%g %g, %g %g, %g %g) is %g (side is %d), quadrants:%g", first.x, first.y, center.x, center.y, b.x, b.y, angle, p2_side, num_quadrants);
}
/* a1 is first point, b is last point */
if ( arc_edges < min_quad_edges * num_quadrants ) {
/* If surface is not 3D, it's can't be closed */
if (!FLAGS_GET_Z(tin->flags)) return 0;
- /* Max theorical arcs number if no one is shared ... */
+ /* Max theoretical arcs number if no one is shared ... */
narcs = 3 * tin->ngeoms;
arcs = lwalloc(sizeof(struct struct_tin_arcs) * narcs);
/*
* Construct a triangle from a LWLINE being
* the shell
- * Pointarray from intput geom are cloned.
+ * Pointarray from input geom is cloned.
* Input line must have 4 points, and be closed.
*/
LWTRIANGLE *
* The caller should specify start or end truncation by setting the truncdirection
* parameter as follows:
* 0 - start truncation (i.e. characters are removed from the beginning)
- * 1 - end trunctation (i.e. characters are removed from the end)
+ * 1 - end truncation (i.e. characters are removed from the end)
*/
char *lwmessage_truncate(char *str, int startpos, int endpos, int maxlength, int truncdirection)
char
getMachineEndian(void)
{
- static int endian_check_int = 1; /* dont modify this!!! */
+ static int endian_check_int = 1; /* don't modify this!!! */
return *((char *) &endian_check_int); /* 0 = big endian | xdr,
* 1 = little endian | ndr
/**
-Function initialazing max distance calculation
+Function initializing max distance calculation
*/
double
lwgeom_maxdistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
}
/**
-Function handling max distance calculations and dfyllywithin calculations.
+Function handling max distance calculations and dfullywithin calculations.
The difference is just the tolerance.
*/
double
}
/**
- Function initialazing min distance calculation
+ Function initializing min distance calculation
*/
double
lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
}
/**
-This is a recursive function delivering every possible combinatin of subgeometries
+This is a recursive function delivering every possible combination of subgeometries
*/
int lw_dist2d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl)
{
lwgeom_add_bbox(g2);
}
- /*If one of geometries is empty, return. True here only means continue searching. False would have stoped the process*/
+ /*If one of geometries is empty, return. True here only means continue searching. False would have stopped the process*/
if (lwgeom_is_empty(g1)||lwgeom_is_empty(g2)) return LW_TRUE;
if ( (dl->mode != DIST_MAX) &&
2 check if poly1 has first point outside poly2 and vice versa, if so, just check outer rings
3 check if first point of poly2 is in a hole of poly1. If so check outer ring of poly2 against that hole of poly1
4 check if first point of poly1 is in a hole of poly2. If so check outer ring of poly1 against that hole of poly2
-5 If we have come all the way here we know that the first point of one of them is inside the other ones outer ring and not in holes so we check wich one is inside.
+5 If we have come all the way here we know that the first point of one of them is inside the other ones outer ring and not in holes so we check which one is inside.
*/
int
lw_dist2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS *dl)
/* 2 check if poly1 has first point outside poly2 and vice versa, if so, just check outer rings
- here it would be possible to handle the information about wich one is inside wich one and only search for the smaller ones in the bigger ones holes.*/
+ here it would be possible to handle the information about which one is inside which one and only search for the smaller ones in the bigger ones holes.*/
pt = getPoint2d_cp(poly1->rings[0], 0);
if ( ptarray_contains_point(poly2->rings[0], pt) == LW_OUTSIDE )
{
/* 2 check if poly1 has first point outside poly2 and vice versa, if so, just check outer rings
- here it would be possible to handle the information about wich one is inside wich one and only search for the smaller ones in the bigger ones holes.*/
+ here it would be possible to handle the information about which one is inside which one and only search for the smaller ones in the bigger ones holes.*/
pt = lw_curvering_getfirstpoint2d_cp(poly1->rings[0]);
if ( lwgeom_contains_point(poly2->rings[0], pt) == LW_OUTSIDE )
{
}
- /*5 If we have come all the way here we know that the first point of one of them is inside the other ones outer ring and not in holes so we check wich one is inside.*/
+ /*5 If we have come all the way here we know that the first point of one of them is inside the other ones outer ring and not in holes so we check which one is inside.*/
pt = lw_curvering_getfirstpoint2d_cp(poly1->rings[0]);
if ( lwgeom_contains_point(poly2->rings[0], pt) != LW_OUTSIDE )
{
/* Calculate center and radius of the circle. */
radius_C = lw_arc_center(B1, B2, B3, &C);
- /* This "arc" is actually a line (B2 is colinear with B1,B3) */
+ /* This "arc" is actually a line (B2 is collinear with B1,B3) */
if ( radius_C < 0.0 )
return lw_dist2d_seg_seg(A1, A2, B1, B3, dl);
if ( dist_C_D < radius_C )
{
double length_A; /* length of the segment A */
- POINT2D E, F; /* points of interection of edge A and circle(B) */
+ POINT2D E, F; /* points of intersection of edge A and circle(B) */
double dist_D_EF; /* distance from D to E or F (same distance both ways) */
dist_D_EF = sqrt(radius_C*radius_C - dist_C_D*dist_C_D);
F.y = D.y + (A2->y-A1->y) * dist_D_EF / length_A;
- /* If E is within A and within B then it's an interesction point */
+ /* If E is within A and within B then it's an intersection point */
pt_in_arc = lw_pt_in_arc(&E, B1, B2, B3);
pt_in_seg = lw_pt_in_seg(&E, A1, A2);
return LW_TRUE;
}
- /* If F is within A and within B then it's an interesction point */
+ /* If F is within A and within B then it's an intersection point */
pt_in_arc = lw_pt_in_arc(&F, B1, B2, B3);
pt_in_seg = lw_pt_in_seg(&F, A1, A2);
/**
Finds the shortest distance between two segments.
-This function is changed so it is not doing any comparasion of distance
+This function is changed so it is not doing any comparison of distance
but just sending every possible combination further to lw_dist2d_pt_seg
*/
int
{
if ((lw_dist2d_pt_seg(A,C,D,dl)) && (lw_dist2d_pt_seg(B,C,D,dl)))
{
- dl->twisted= ((dl->twisted) * (-1)); /*here we change the order of inputted geometrys and that we notice by changing sign on dl->twisted*/
+ dl->twisted= ((dl->twisted) * (-1)); /*here we change the order of inputted geometries and that we notice by changing sign on dl->twisted*/
return ((lw_dist2d_pt_seg(C,A,B,dl)) && (lw_dist2d_pt_seg(D,A,B,dl))); /*if all is successful we return true*/
}
else
{
if ((lw_dist2d_pt_seg(A,C,D,dl)) && (lw_dist2d_pt_seg(B,C,D,dl)))
{
- dl->twisted= ((dl->twisted) * (-1)); /*here we change the order of inputted geometrys and that we notice by changing sign on dl->twisted*/
+ dl->twisted= ((dl->twisted) * (-1)); /*here we change the order of inputted geometries and that we notice by changing sign on dl->twisted*/
return ((lw_dist2d_pt_seg(C,A,B,dl)) && (lw_dist2d_pt_seg(D,A,B,dl))); /*if all is successful we return true*/
}
else
}
- /*if the center-center line is horizontal the perpendicular line will be vertical. To eliminate problems with deviding by zero we are here mirroring the coordinate-system
+ /*if the center-center line is horizontal the perpendicular line will be vertical. To eliminate problems with dividing by zero we are here mirroring the coordinate-system
and we find it's crossing the X-axes with z = x-(1/k)y */
else /*West or East*/
{
p3 = getPoint2d_cp(l2, list2[0].pnr);
lw_dist2d_pt_pt(p1, p3, dl);
maxmeasure = sqrt(dl->distance*dl->distance + (dl->distance*dl->distance*k*k));
- twist = dl->twisted; /*to keep the incomming order between iterations*/
+ twist = dl->twisted; /*to keep the incoming order between iterations*/
for (i =(n1-1); i>=0; --i)
{
/*we break this iteration when we have checked every
point closer to our perpendicular "checkline" than
our shortest found distance*/
if (((list2[0].themeasure-list1[i].themeasure)) > maxmeasure) break;
- for (r=-1; r<=1; r +=2) /*because we are not iterating in the original pointorder we have to check the segment before and after every point*/
+ for (r=-1; r<=1; r +=2) /*because we are not iterating in the original point order we have to check the segment before and after every point*/
{
pnr1 = list1[i].pnr;
p1 = getPoint2d_cp(l1, pnr1);
/**
lw_dist2d_comp from p to line A->B
-This one is now sending every occation to lw_dist2d_pt_pt
-Before it was handling occations where r was between 0 and 1 internally
+This one is now sending every occasion to lw_dist2d_pt_pt
+Before it was handling occasions where r was between 0 and 1 internally
and just returning the distance without identifying the points.
-To get this points it was nessecary to change and it also showed to be about 10%faster.
+To get this points it was necessary to change and it also showed to be about 10%faster.
*/
int
lw_dist2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B, DISTPTS *dl)
/*This is for finding the maxdistance.
the maxdistance have to be between two vertexes,
compared to mindistance which can be between
- tvo vertexes vertex.*/
+ two vertexes vertex.*/
if (dl->mode == DIST_MAX)
{
if (r>=0.5)
/**
-Compares incomming points and
+Compares incoming points and
stores the points closest to each other
or most far away from each other
depending on dl->mode (max or min)
/**
-The old function nessecary for ptarray_segmentize2d in ptarray.c
+The old function necessary for ptarray_segmentize2d in ptarray.c
*/
double
distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
/**
-The old function nessecary for ptarray_segmentize2d in ptarray.c
+The old function necessary for ptarray_segmentize2d in ptarray.c
*/
double
distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
POINT2D p1;
POINT2D p2;
int mode; /*the direction of looking, if thedir = -1 then we look for maxdistance and if it is 1 then we look for mindistance*/
- int twisted; /*To preserve the order of incoming points to match the first and secon point in shortest and longest line*/
+ int twisted; /*To preserve the order of incoming points to match the first and second point in shortest and longest line*/
double tolerance; /*the tolerance for dwithin and dfullywithin*/
} DISTPTS;
/**
This function is used to create a vertical line used for cases where one if the
geometries lacks z-values. The vertical line crosses the 2d point that is closest
-and the z-range is from maxz to minz in the geoemtrie that has z values.
+and the z-range is from maxz to minz in the geometry that has z values.
*/
static
LWGEOM* create_v_line(const LWGEOM *lwgeom,double x, double y, int srid)
thedl.distance = initdistance;
thedl.tolerance = 0.0;
- /*Check if we really have 3D geoemtries*/
+ /*Check if we really have 3D geometries*/
/*If not, send it to 2D-calculations which will give the same result*/
/*as an infinite z-value at one or two of the geometries*/
if(!lwgeom_has_z(lw1) || !lwgeom_has_z(lw2))
LWDEBUG(2, "lw_dist3d_distancepoint is called");
- /*Check if we really have 3D geoemtries*/
+ /*Check if we really have 3D geometries*/
/*If not, send it to 2D-calculations which will give the same result*/
/*as an infinite z-value at one or two of the geometries*/
if(!lwgeom_has_z(lw1) || !lwgeom_has_z(lw2))
}
- /*If one of geometries is empty, return. True here only means continue searching. False would have stoped the process*/
+ /*If one of geometries is empty, return. True here only means continue searching. False would have stopped the process*/
if (lwgeom_is_empty(g1)||lwgeom_is_empty(g2)) return LW_TRUE;
LWDEBUG(2, "lw_dist3d_point_poly is called");
getPoint3dz_p(point->point, 0, &p);
- /*If we are lookig for max distance, longestline or dfullywithin*/
+ /*If we are looking for max distance, longestline or dfullywithin*/
if (dl->mode == DIST_MAX)
{
LWDEBUG(3, "looking for maxdistance");
if(!define_plane(poly2->rings[0], &plane))
return LW_FALSE;
- /*What we do here is to compare the bondary of one polygon with the other polygon
- and then take the second boudary comparing with the first polygon*/
+ /*What we do here is to compare the boundary of one polygon with the other polygon
+ and then take the second boundary comparing with the first polygon*/
dl->twisted=1;
if(!lw_dist3d_ptarray_poly(poly1->rings[0], poly2,&plane, dl))
return LW_FALSE;
if(!define_plane(poly1->rings[0], &plane))
return LW_FALSE;
- dl->twisted=-1; /*because we swithc the order of geometries we swithch "twisted" to -1 which will give the right order of points in shortest line.*/
+ dl->twisted=-1; /*because we switch the order of geometries we switch "twisted" to -1 which will give the right order of points in shortest line.*/
return lw_dist3d_ptarray_poly(poly2->rings[0], poly1,&plane, dl);
}
/*This is for finding the 3Dmaxdistance.
the maxdistance have to be between two vertexes,
compared to mindistance which can be between
- tvo vertexes vertex.*/
+ two vertexes vertex.*/
if (dl->mode == DIST_MAX)
{
if (r>=0.5)
/**
-Compares incomming points and
+Compares incoming points and
stores the points closest to each other
or most far away from each other
depending on dl->mode (max or min)
/**
-Finds all combinationes of segments between two pointarrays
+Finds all combinations of segments between two pointarrays
*/
int
lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS3D *dl)
if (D <0.000000001)
{ /* the lines are almost parallel*/
- s1k = 0.0; /*If the lines are paralell we try by using the startpoint of first segment. If that gives a projected point on the second line outside segment 2 it wil be found that s2k is >1 or <0.*/
+ s1k = 0.0; /*If the lines are parallel we try by using the startpoint of first segment. If that gives a projected point on the second line outside segment 2 it wil be found that s2k is >1 or <0.*/
if(b>c) /* use the largest denominator*/
{
s2k=d/b;
Checking if the point projected on the plane of the polygon actually is inside that polygon.
If so the mindistance is between that projected point and our original point.
-If not we check from original point to the bounadary.
-If the projected point is inside a hole of the polygon we check the distance to the boudary of that hole.
+If not we check from original point to the boundary.
+If the projected point is inside a hole of the polygon we check the distance to the boundary of that hole.
*/
int
lw_dist3d_pt_poly(POINT3DZ *p, LWPOLY *poly, PLANE3D *plane,POINT3DZ *projp, DISTPTS3D *dl)
}
else
{
- return lw_dist3d_pt_ptarray(p, poly->rings[0], dl); /*If the projected point is outside the polygon we search for the closest distance against the boundarry instead*/
+ return lw_dist3d_pt_ptarray(p, poly->rings[0], dl); /*If the projected point is outside the polygon we search for the closest distance against the boundary instead*/
}
return LW_TRUE;
/**
Here we define the plane of a polygon (boundary pointarray of a polygon)
-the plane is stored as a pont in plane (plane.pop) and a normal vector (plane.pv)
+the plane is stored as a point in plane (plane.pop) and a normal vector (plane.pv)
*/
int
define_plane(POINTARRAY *pa, PLANE3D *pl)
double
project_point_on_plane(POINT3DZ *p, PLANE3D *pl, POINT3DZ *p0)
{
-/*In our plane definition we have a point on the plane and a normal vektor (pl.pv), perpendicular to the plane
-this vector will be paralell to the line between our inputted point above the plane and the point we are searching for on the plane.
+/*In our plane definition we have a point on the plane and a normal vector (pl.pv), perpendicular to the plane
+this vector will be parallel to the line between our inputted point above the plane and the point we are searching for on the plane.
So, we already have a direction from p to find p0, but we don't know the distance.
*/
POINTARRAY *pa = lwalloc(sizeof(POINTARRAY));
pa->serialized_pointlist = NULL;
- /* Set our dimsionality info on the bitmap */
+ /* Set our dimensionality info on the bitmap */
pa->flags = gflags(hasz, hasm, 0);
/* We will be allocating a bit of room */
/* Error out if we have a bad situation */
if ( pa->npoints > pa->maxpoints )
{
- lwerror("npoints (%d) is greated than maxpoints (%d)", pa->npoints, pa->maxpoints);
+ lwerror("npoints (%d) is greater than maxpoints (%d)", pa->npoints, pa->maxpoints);
return LW_FAILURE;
}
/*
* If the point is to the left of the line, and it's rising,
* then the line is to the right of the point and
- * circling counter-clockwise, so incremement.
+ * circling counter-clockwise, so increment.
*/
if ( (side < 0) && (seg1->y <= pt->y) && (pt->y < seg2->y) )
{
}
/**
-* If necessary, expand the stringbuffer_t internal buffer to accomodate the
+* If necessary, expand the stringbuffer_t internal buffer to accommodate the
* specified additional size.
*/
static inline void
{
/* In the next line quite a lot is happening. */
/* Since there is more to read in our input value */
- /* we signal that by setting the most siginicant bit */
+ /* we signal that by setting the most significant bit */
/* in our byte to 1. */
/* Then we put that byte in our buffer and move the pointer */
/* forward one step */
box_key = (BOX2DF *) column->bv_values[INCLUSION_UNION];
- /* Check if the stored bouding box already contains the geometry's one */
+ /* Check if the stored bounding box already contains the geometry's one */
if (box2df_contains(box_key, &box_geom))
PG_RETURN_BOOL(false);
* We first consider splits where b is the lower bound of an entry.
* We iterate through all entries, and for each b, calculate the
* smallest possible a. Then we consider splits where a is the
- * uppper bound of an entry, and for each a, calculate the greatest
+ * upper bound of an entry, and for each a, calculate the greatest
* possible b.
*
* In the above example, the first loop would consider splits:
}
/*
- * Iterate over upper bound of left group finding greates possible
+ * Iterate over upper bound of left group finding greatest possible
* lower bound of right group.
*/
i1 = nentries - 1;
#include "legacy_minimal.sql.in"
--- start functions that in theory should never have been used or internal like stuff deprecated
--- these were superceded by PostGIS_AddBBOX , PostGIS_DropBBOX, PostGIS_HasBBOX in 1.5 --
+-- these were superseded by PostGIS_AddBBOX , PostGIS_DropBBOX, PostGIS_HasBBOX in 1.5 --
CREATE OR REPLACE FUNCTION addbbox(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_addBBOX'
nitems = sscanf(str,"box(%lf %lf,%lf %lf)", &box.xmin, &box.ymin, &box.xmax, &box.ymax);
if (nitems != 4)
{
- elog(ERROR,"box2d parser - couldnt parse. It should look like: BOX(xmin ymin,xmax ymax)");
+ elog(ERROR,"box2d parser - couldn't parse. It should look like: BOX(xmin ymin,xmax ymax)");
PG_RETURN_NULL();
}
if (nitems != 4)
{
pfree(box);
- elog(ERROR,"BOX3D parser - couldnt parse. It should look like: BOX3D(xmin ymin zmin,xmax ymax zmax) or BOX3D(xmin ymin,xmax ymax)");
+ elog(ERROR,"BOX3D parser - couldn't parse. It should look like: BOX3D(xmin ymin zmin,xmax ymax zmax) or BOX3D(xmin ymin,xmax ymax)");
PG_RETURN_NULL();
}
}
/*
* If the point is to the left of the line, and it's rising,
* then the line is to the right of the point and
- * circling counter-clockwise, so incremement.
+ * circling counter-clockwise, so increment.
*/
if (FP_CONTAINS_BOTTOM(seg1->y, point->y, seg2->y) && side>0)
{
/*
* If the point is to the left of the line, and it's rising,
* then the line is to the right of the point and
- * circling counter-clockwise, so incremement.
+ * circling counter-clockwise, so increment.
*/
if (FP_CONTAINS_BOTTOM(seg1->y, point->y, seg2->y) && side>0)
{
return NULL;
}
- lwpgerror("Unkonwn geometry type (%s:%d)", __FILE__, __LINE__);
+ lwpgerror("Unknown geometry type (%s:%d)", __FILE__, __LINE__);
return NULL;
}
* Returns at most components as a collection.
* First element of the collection is always the part which
* remains after the cut, while the second element is the
- * part which has been cut out. We arbitrarely take the part
+ * part which has been cut out. We arbitrarily take the part
* on the *right* of cut lines as the part which has been cut out.
* For a line cut by a point the part which remains is the one
* from start of the line to the cut point.
pghe = GetPrepGeomHashEntry(context);
if (!pghe)
- elog(ERROR, "PreparedCacheDelete: Trying to delete non-existant hash entry object with MemoryContext key (%p)", (void *)context);
+ elog(ERROR, "PreparedCacheDelete: Trying to delete non-existent hash entry object with MemoryContext key (%p)", (void *)context);
POSTGIS_DEBUGF(3, "deleting geom object (%p) and prepared geom object (%p) with MemoryContext key (%p)", pghe->geom, pghe->prepared_geom, context);
/**
- * Retrieve a GML propertie from a node or NULL otherwise
+ * Retrieve a GML property from a node or NULL otherwise
* Respect namespaces if presents in the node element
*/
static xmlChar *gmlGetProp(xmlNodePtr xnode, xmlChar *prop)
if (!is_gml_namespace(xa, false)) continue;
if (strcmp((char *) xa->name, "LineStringSegment")) continue;
- /* GML SF is resticted to linear interpolation */
+ /* GML SF is restricted to linear interpolation */
interpolation = gmlGetProp(xa, (xmlChar *) "interpolation");
if (interpolation != NULL)
{
* segment" from ISO 19107:2003 -> 6.3.16.1 (p43)
*
* So we must aggregate all the segments into a single one and avoid
- * to copy the redundants points
+ * to copy the redundant points
*/
if (lss > 1)
{
if (xnode->children == NULL)
return lwtriangle_as_lwgeom(lwtriangle_construct_empty(*root_srid, 0, 0));
- /* GML SF is resticted to planar interpolation
+ /* GML SF is restricted to planar interpolation
NOTA: I know Triangle is not part of SF, but
we have to be consistent with other surfaces */
interpolation = gmlGetProp(xnode, (xmlChar *) "interpolation");
if (strcmp((char *) xnode->name, "PolygonPatch"))
gml_lwpgerror("invalid GML representation", 48);
- /* GML SF is resticted to planar interpolation */
+ /* GML SF is restricted to planar interpolation */
interpolation = gmlGetProp(xnode, (xmlChar *) "interpolation");
if (interpolation != NULL)
{
ptarray_append_point(dpa, &pt, LW_TRUE);
kml_dims = 0;
}
- p = q-1; /* will be incrementedon next iteration */
+ p = q-1; /* will be incremented on next iteration */
//lwpgnotice("after look-ahead *p:%c, kml_dims:%d", *p, kml_dims);
} else if ( *p != ',' && ! isspace(*p) ) {
lwpgerror("invalid KML representation"); /* (unexpected character %c)", *p); */
idlist = palloc0(num_geoms * sizeof(int64_t));
- /*Check if there is differences in dimmenstionality*/
+ /* Check if there is differences in dimensionality*/
if( lwgeom_has_z(geom)!=has_z || lwgeom_has_m(geom)!=has_m)
{
- elog(ERROR, "Geometries have differenct dimensionality");
+ elog(ERROR, "Geometries have different dimensionality");
PG_FREE_IF_COPY(arr_geoms, 0);
PG_FREE_IF_COPY(arr_ids, 1);
PG_RETURN_NULL();
* Its radius is approximated by looking at the ellipse. Near the equator R = 'a' (earth's major axis)
* near the pole R = 'b' (earth's minor axis).
*
- * The second (S) is basically a (east-west) line of lattitude.
+ * The second (S) is basically a (east-west) line of latitude.
* Its radius runs from 'a' (major axis) at the equator, and near 0 at the poles.
*
*
* Angle A is lat1
* R is the distance from the centre of the earth to the lat1/long1 point on the surface
* of the Earth.
- * S is the circle-of-lattitude. Its calculated from the right triangle defined by
- * the angle (90-A), and the hypothenus R.
+ * S is the circle-of-latitude. Its calculated from the right triangle defined by
+ * the angle (90-A), and the hypotenuse R.
*
*
*