*/
typedef struct
{
- int64_t id; //Id, from function parameter
- LWGEOM* geom; //the geometry from function parameter
+ int64_t id; /* Id, from function parameter */
+ LWGEOM* geom; /* the geometry from function parameter */
}
lwgeom_id;
int num_parents = 0;
int j;
- // TODO, roll geom_type *up* as tree is built, changing to collection types as simple types are merged
- // TODO, change the distance algorithm to drive down to simple types first, test pip on poly/other cases, then test edges
+ /* TODO, roll geom_type *up* as tree is built, changing to collection types as simple types are merged
+ * TODO, change the distance algorithm to drive down to simple types first, test pip on poly/other cases, then test edges
+ */
while( num_children > 1 )
{
int i;
LWDEBUGF(4, "entered, min_dist=%.8g max_dist=%.8g, type1=%d, type2=%d", *min_dist, *max_dist, n1->geom_type, n2->geom_type);
-// circ_tree_print(n1, 0);
-// circ_tree_print(n2, 0);
+/*
+ circ_tree_print(n1, 0);
+ circ_tree_print(n2, 0);
+*/
/* Short circuit if we've already hit the minimum */
if( *min_dist <= threshold )
#endif
#ifndef JSON_C_VERSION
-// Adds support for libjson < 0.10
+/* Adds support for libjson < 0.10 */
# define json_tokener_error_desc(x) json_tokener_errors[(x)]
#endif
return LW_FAILURE;
}
- // Read X coordinate
+ /* Read X coordinate */
poObjCoord = json_object_array_get_idx( poObj, 0 );
pt.x = json_object_get_double( poObjCoord );
LWDEBUGF(3, "parse_geojson_coord pt.x = %f.", pt.x );
- // Read Y coordinate
+ /* Read Y coordinate */
poObjCoord = json_object_array_get_idx( poObj, 1 );
pt.y = json_object_get_double( poObjCoord );
LWDEBUGF(3, "parse_geojson_coord pt.y = %f.", pt.y );
if( nSize > 2 ) /* should this be >= 3 ? */
{
- // Read Z coordinate
+ /* Read Z coordinate */
poObjCoord = json_object_array_get_idx( poObj, 2 );
pt.z = json_object_get_double( poObjCoord );
LWDEBUGF(3, "parse_geojson_coord pt.z = %f.", pt.z );
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
POINTARRAY *pa = ptarray_from_twkb_state(s,npoints);
return lwpoint_construct(0, NULL, pa);
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
/*get number of points*/
npoints = varint_u64_read(&(s->pos), s->twkb_end);
int i;
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
/*get number of rings*/
nrings= varint_u64_read(&(s->pos), s->twkb_end);
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
/*Now we switch off id reading for subgeometries*/
s->read_id=LW_FALSE;
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
/*Now we switch off id reading for subgeometries*/
s->read_id=LW_FALSE;
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
/*Now we switch off id reading for subgeometries*/
s->read_id=LW_FALSE;
/* TODO, make an option to use the id-value and return a set with geometry and id*/
if((s->magic_byte&TWKB_ID) && s->read_id)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over id value
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over id value */
/*Now we switch off id reading for subgeometries*/
s->read_id=LW_FALSE;
/*If the twkb-geometry has size information we just jump over it*/
if(s->magic_byte&TWKB_SIZES)
- varint_64_jump_n(&(s->pos),1, s->twkb_end); //Jump over size information
+ varint_64_jump_n(&(s->pos),1, s->twkb_end); /* Jump over size info */
/*If our dataset has bboxes we just set a flag for that. We cannot do anything about it before we know the number of dimmensions*/
if(s->magic_byte&TWKB_BBOXES)
/*Now we know number of dommensions so we can jump over the bboxes with right number of "jumps"*/
if (s->has_bboxes)
{
- varint_64_jump_n(&(s->pos),2*(s->ndims), s->twkb_end); //Jump over bbox
+ varint_64_jump_n(&(s->pos),2*(s->ndims), s->twkb_end); /* Jump over bbox */
/*We only have bboxes at top level, so once found we forget about it*/
s->has_bboxes=LW_FALSE;
}
double *dbl_ptr;
/*The variable factor is used to "shift" the double float coordinate to keep enough significant digits,
for demanded precision, when cast to integer*/
-// factor=pow(10,prec);
+/* factor=pow(10,prec); */
/* Include the npoints size if it's not a POINT type) */
if ( ! ( variant & WKB_NO_NPOINTS ) )
{
int dims = FLAGS_NDIMS(pa->flags);
int i, j;
double *dbl_ptr;
- //factor=pow(10,prec);
+ /*factor=pow(10,prec);*/
varint_s64_encode_buf(r,buf);
}
}
- //LWDEBUGF(4, "Done (buf = %p)", buf);
+ /* LWDEBUGF(4, "Done (buf = %p)", buf); */
return 0;
}
if(*variant&TWKB_BBOXES)
{
write_bbox(buf,dims,refpoint[1],refpoint[2]);
- //So we only write bboxes to highest level
+ /* So we only write bboxes to highest level */
*variant = *variant & ~TWKB_BBOXES;
}
if(*variant&TWKB_BBOXES)
{
write_bbox(buf,dims,refpoint[1],refpoint[2]);
- //So we only write bboxes to highest level
+ /* So we only write bboxes to highest level */
*variant = *variant & ~TWKB_BBOXES;
}
if(*variant&TWKB_BBOXES)
{
write_bbox(buf,dims,refpoint[1],refpoint[2]);
- //So we only write bboxes to highest level
+ /* So we only write bboxes to highest level */
*variant = *variant & ~TWKB_BBOXES;
}
if(*variant&TWKB_BBOXES)
{
write_bbox(buf,dims,refpoint[1],refpoint[2]);
- //So we only write bboxes to highest level
+ /* So we only write bboxes to highest level */
*variant = *variant & ~TWKB_BBOXES;
}
case MULTIPOLYGONTYPE:
*variant =*variant | TWKB_NO_TYPE;
size += lwcollection_to_twkb_size((LWCOLLECTION*)geom,variant, factor,id,refpoint);
- //We need to get back the possibility to write types
+ /* We need to get back the possibility to write types */
*variant =*variant & ~TWKB_NO_TYPE;
break;
case COLLECTIONTYPE:
if(*variant&TWKB_BBOXES)
{
write_bbox(buf,FLAGS_NDIMS(geom->flags),refpoint[1],refpoint[2]);
- //So we only write bboxes to highest level
+ /* So we only write bboxes to highest level */
*variant = *variant & ~TWKB_BBOXES;
}
}
/*the NO_TYPE flag tells that the type not shall be repeated for subgeometries*/
*variant=*variant | TWKB_NO_TYPE;
res= lwcollection_to_twkb_buf((LWCOLLECTION*)geom, buf, variant,factor,id,refpoint);
- //We need to get back the possibility to write types
+ /* We need to get back the possibility to write types */
*variant =*variant & ~TWKB_NO_TYPE;
return res;
}
LWDEBUGF(4, "WKB output size: %d", buf_size);
- //add the size of the bbox
- // If empty geometry request for bbox is ignored
+ /* add the size of the bbox
+ * If empty geometry request for bbox is ignored */
if(variant&TWKB_BBOXES)
{
LWDEBUG(4,"We want boxes and will calculate required size");
}
- //reset refpoints
+ /* reset refpoints */
refpoint[0][0]=refpoint[0][1]=refpoint[0][2]=refpoint[0][3]=0;
if (lwgeom_arrays->n_collections > 0)
buf_size += lwgeom_agg_to_twkbcollection_size(lwgeom_arrays->collections,&variant,lwgeom_arrays->n_collections, factor,refpoint);
- //add the size of the bbox
- // If empty geometry request for bbox is ignored
+ /* add the size of the bbox
+ * If empty geometry request for bbox is ignored */
if(variant&TWKB_BBOXES)
{
LWDEBUG(4,"We want boxes and will calculate required size");
- //Check how many dimmensions that have been used for the box
+ /* Check how many dimmensions that have been used for the box */
while (nDims<MAX_N_DIMS&&refpoint[1][nDims]<INT64_MAX&&refpoint[2][nDims]>INT64_MIN)
nDims++;
buf_size += sizeof_bbox(nDims,refpoint[1],refpoint[2]);
}
- //reset refpoints
+ /* reset refpoints */
refpoint[0][0]=refpoint[0][1]=refpoint[0][2]=refpoint[0][3]=0;
LWDEBUGF(4, "WKB output size: %d", buf_size);
#include "lwgeom_log.h"
#include <limits.h>
-//Maximum number of geometry dimmensions that internal arrays can hold
+/* Maximum number of geometry dimmensions that internal arrays can hold */
#define MAX_N_DIMS 4
/**
static size_t lwgeom_to_twkb_size(const LWGEOM *geom, uint8_t *variant, int64_t factor, int64_t id,int64_t refpoint[3][4]);
static int lwgeom_to_twkb_buf(const LWGEOM *geom, uint8_t **buf, uint8_t *variant,int64_t factor, int64_t id,int64_t refpoint[3][4]);
-
-//static size_t lwgeom_to_twkb_size(const LWGEOM *geom, uint8_t variant,int64_t factor);
-
size_t defidlen = strlen(defid);
LWGEOM *subgeom;
- //size = sizeof("<MultiGeometry></MultiGeometry>") + defidlen*2;
+ /* size = sizeof("<MultiGeometry></MultiGeometry>") + defidlen*2; */
size = defidlen*2;
/** if ( srs )
/* Open outmost tag */
/** @TODO: decide if we need outtermost tags, this one was just a copy from gml so is wrong **/
+#ifdef PGIS_X3D_OUTERMOST_TAGS
if ( srs )
{
- //ptr += sprintf(ptr, "<%sMultiGeometry srsName=\"%s\">", defid, srs);
+ ptr += sprintf(ptr, "<%sMultiGeometry srsName=\"%s\">", defid, srs);
}
else
{
- //ptr += sprintf(ptr, "<%sMultiGeometry>", defid);
+ ptr += sprintf(ptr, "<%sMultiGeometry>", defid);
}
+#endif
for (i=0; i<col->ngeoms; i++)
{
}
/* Close outmost tag */
- //ptr += sprintf(ptr, "</%sMultiGeometry>", defid);
+#ifdef PGIS_X3D_OUTERMOST_TAGS
+ ptr += sprintf(ptr, "</%sMultiGeometry>", defid);
+#endif
return (ptr-output);
}
uint64_t q=val;
while (1)
{
- grp=127&q; //We put the 7 least significant bits in grp
- q=q>>7; //We rightshift our input value 7 bits which means that the 7 next least significant bits becomes the 7 least significant
- if(q>0) // Check if, after our rightshifting, we still have anything to read in our input value.
+ grp=127&q; /* We put the 7 least significant bits in grp */
+ q=q>>7; /* We rightshift our input value 7 bits which means that the 7 next least significant bits becomes the 7 least significant */
+ if(q>0) /* Check if, after our rightshifting, we still have anything to read in our input value. */
{
/*In the next line quite a lot is happening.
Since there is more to read in our input value we signalize that by setting the most siginicant bit in our byte to 1.
{
/*The same as above, but since there is nothing more to read in our input value we leave the most significant bit unset*/
*((*buf)++)=grp;
- // printf("grp1:%d\n",(int) grp);
+ /* printf("grp1:%d\n",(int) grp); */
return 0;
}
}
int nShift = 0;
uint8_t nByte;
- while(*data<=the_end)//Check so we don't read beyond the twkb
+ while(*data<=the_end)/* Check so we don't read beyond the twkb */
{
- nByte = (uint8_t) **data; //read a byte
- if (!(nByte & 0x80)) //If it is the last byte in the varInt ....
+ nByte = (uint8_t) **data; /* read a byte */
+ if (!(nByte & 0x80)) /* is the last byte in the varInt .... */
{
- (*data) ++; //move the "cursor" one step
- return nVal | ((uint64_t)nByte << nShift); //Move the last read byte to the most significant place in the result and return the whole result
+ (*data) ++; /* move the "cursor" one step */
+ return nVal | ((uint64_t)nByte << nShift); /* Move the last read byte to the most significant place in the result and return the whole result */
}
/*We get here when there is more to read in the input varInt*/
- nVal |= ((uint64_t)(nByte & 0x7f)) << nShift; //Here we take the least significant 7 bits of the read byte and put it in the most significant place in the result variable.
- (*data) ++; //move the "cursor" of the input buffer step (8 bits)
- nShift += 7; //move the cursor in the resulting variable (7 bits)
+ nVal |= ((uint64_t)(nByte & 0x7f)) << nShift; /* Here we take the least significant 7 bits of the read byte and put it in the most significant place in the result variable. */
+ (*data) ++; /* move the "cursor" of the input buffer step (8 bits) */
+ nShift += 7; /* move the cursor in the resulting variable (7 bits) */
}
lwerror("VarInt value goes beyond TWKB");
return 0;
void varint_64_jump_n(uint8_t **data, int nValues, uint8_t *the_end)
{
uint8_t nByte;
- while(nValues>0)//Check so we don't read beyond the twkb
+ while(nValues>0)/* Check so we don't read beyond the twkb */
{
if(*data>the_end)
lwerror("VarInt value goes beyond TWKB");
- nByte = (uint8_t) **data; //read a byte
- if (!(nByte & 0x80)) //If it is the last byte in the varInt ....
+ nByte = (uint8_t) **data; /* read a byte */
+ if (!(nByte & 0x80)) /* If it is the last byte in the varInt .... */
{
- nValues--;//...We count one more varint
+ nValues--;/*...We count one more varint */
}
- (*data) ++; //move the "cursor" of the input buffer step (8 bits)
+ (*data) ++; /* move the "cursor" of the input buffer step (8 bits) */
}
return;
}
DBFCreate( const char * pszFilename )
{
- return DBFCreateEx( pszFilename, "LDID/87" ); // 0x57
+ return DBFCreateEx( pszFilename, "LDID/87" ); /* 0x57 */
}
/************************************************************************/
{
ldid = atoi( pszCodePage + 5 );
if( ldid > 255 )
- ldid = -1; // don't use 0 to indicate out of range as LDID/0 is a valid one
+ ldid = -1; /* don't use 0 to indicate out of range as LDID/0 is a valid one */
}
if( ldid < 0 )
{
case 'D':
/* NULL date fields have value "00000000" or blank or empty */
- if (pszValue[0] == '\0' || // emtpy string
+ if (pszValue[0] == '\0' || /* emtpy string */
strncmp(pszValue,"00000000",8) == 0 ||
strncmp(pszValue," ",8) == 0) {
return 1;
} else {
return 0;
}
- // return strncmp(pszValue,"00000000",8) == 0;
+ /* return strncmp(pszValue,"00000000",8) == 0; */
case 'L':
/* NULL boolean fields have value "?" or empty */
/* If a user-defined query has been specified, create and point the state to our new table */
if (state->config->usrquery)
{
- state->table = malloc(20 + 20); // string + max long precision
+ state->table = malloc(20 + 20); /* string + max long precision */
sprintf(state->table, "__pgsql2shp%lu_tmp_table", (long)getpid());
query = malloc(32 + strlen(state->table) + strlen(state->config->usrquery));
strcpy(progress_shapefile, &loader_file_config->shp_file[i]);
/* Display the progress dialog */
- //lw_asprintf(&progress_text, _("Importing shapefile %s (%d records)..."), progress_shapefile, ShpLoaderGetRecordCount(state));
+ /* lw_asprintf(&progress_text, _("Importing shapefile %s (%d records)..."), progress_shapefile, ShpLoaderGetRecordCount(state)); */
snprintf(progress_text, GUIMSG_LINE_MAXLEN, _("Importing shapefile %s (%d records)..."), progress_shapefile, ShpLoaderGetRecordCount(state));
progress_text[GUIMSG_LINE_MAXLEN] = '\0';
gtk_label_set_text(GTK_LABEL(label_progress), progress_text);
}
/* Update the text */
- //lw_asprintf(&progress_text, _("Exporting table %s (%d records)..."), dumper_table_config->table, ShpDumperGetRecordCount(state));
+ /* lw_asprintf(&progress_text, _("Exporting table %s (%d records)..."), dumper_table_config->table, ShpDumperGetRecordCount(state)); */
snprintf(progress_text, GUIMSG_LINE_MAXLEN, _("Exporting table %s (%d records)..."), dumper_table_config->table, ShpDumperGetRecordCount(state));
progress_text[GUIMSG_LINE_MAXLEN] = '\0';
gtk_label_set_text(GTK_LABEL(label_progress), progress_text);
if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 )
{
unsigned int nExpectedSize = psSHP->nFileSize + nRecordSize;
- if( nExpectedSize < psSHP->nFileSize ) // due to unsigned int overflow
+ if( nExpectedSize < psSHP->nFileSize ) /* due to unsigned int overflow */
{
char str[128];
sprintf( str, "Failed to write shape object. "
(NULL != grid_xw && NULL != grid_xw) &&
FLT_NEQ(*grid_xw, extent.MinX)
) {
- // do nothing
+ /* do nothing */
RASTER_DEBUG(3, "Skipping extent adjustment on X-axis due to upcoming alignment");
}
else {
(NULL != grid_xw && NULL != grid_xw) &&
FLT_NEQ(*grid_yw, extent.MaxY)
) {
- // do nothing
+ /* do nothing */
RASTER_DEBUG(3, "Skipping extent adjustment on Y-axis due to upcoming alignment");
}
else {
(NULL != grid_xw && NULL != grid_xw) &&
FLT_NEQ(*grid_xw, extent.MinX)
) {
- // do nothing
+ /* do nothing */
RASTER_DEBUG(3, "Skipping extent adjustment on X-axis due to upcoming alignment");
}
else {
(NULL != grid_xw && NULL != grid_xw) &&
FLT_NEQ(*grid_yw, extent.MaxY)
) {
- // do nothing
+ /* do nothing */
RASTER_DEBUG(3, "Skipping extent adjustment on Y-axis due to upcoming alignment");
}
else {
*/
#include "../../postgis_config.h"
-//#define POSTGIS_DEBUG_LEVEL 4
+/* #define POSTGIS_DEBUG_LEVEL 4 */
#include "librtcore.h"
#include "librtcore_internal.h"