int i, j;
double *dbl_ptr;
+ /* Nothing to do with a pointarray with no ordinates */
if( pa->npoints < 1 )
+ {
+ lwerror("Point array has < 1 ordinates!");
return buf;
+ }
+
+ /* SFSQL is always 2-d. Extended and ISO use all available dimensions */
if( (variant & WKB_ISO) || (variant & WKB_EXTENDED) )
dims = TYPE_NDIMS(pa->dims);
* Convert LWGEOM to a char* in WKB format. Caller is responsible for freeing
* the returned array.
*
-* Accepts variants:
-* One of: WKB_ISO, WKB_EXTENDED, WKB_SFSQL
-* Any of: WKB_NDR
-* For example, a variant = ( WKT_ISO | WKT_NDR ) would return the little-endian
-* ISO form of WKB.
+* @param variant. Unsigned bitmask value. Accepts one of: WKB_ISO, WKB_EXTENDED, WKB_SFSQL.
+* Accepts any of: WKB_NDR, WKB_HEX. For example: Variant = ( WKB_ISO | WKB_NDR ) would
+* return the little-endian ISO form of WKB. For Example: Variant = ( WKB_EXTENDED | WKB_HEX )
+* would return the big-endian extended form of WKB, as hex-encoded ASCII (the "canonical form").
+* @param size_out If supplied, will return the size of the returned memory segment,
+* including the null terminator in the case of ASCII.
*/
char* lwgeom_to_wkb(const LWGEOM *geom, uchar variant, size_t *size_out)
{
lwfree(wkb_out);
return NULL;
}
+
+ /* Report output size */
+ if( size_out ) *size_out = buf_size;
return wkb_out;
}
* representation. If size_out is not NULL, it will be set to the size of the
* allocated *char.
*
-* Accepts variants:
-* One of: WKT_ISO, WKT_SFSQL, WKT_EXTENDED
+* @param variant Bitmasked value, accepts one of WKT_ISO, WKT_SFSQL, WKT_EXTENDED.
+* @param precision Number of significant digits in the output doubles.
+* @param size_out If supplied, will return the size of the returned string,
+* including the null terminator.
*/
char* lwgeom_to_wkt(const LWGEOM *geom, uchar variant, int precision, size_t *size_out)
{