Check-in [49cd9bc73b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:supporting NDWI Ascii grids and related testcases
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 49cd9bc73b55d3dce1cf6693233ce22ff46e0ac8
User & Date: sandro 2021-02-10 10:07:24
Context
2021-02-18
17:23
fixing RL2_GetMapImageFromVector and GeoTiff output check-in: 9dd8217cb9 user: sandro tags: trunk
2021-02-10
10:07
supporting NDWI Ascii grids and related testcases check-in: 49cd9bc73b user: sandro tags: trunk
2021-01-19
09:34
switching to automake 1.16.2 and fixing a build scripts glitch check-in: 4773a84aa3 user: sandro tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to headers/rasterlite2/rasterlite2.h.

4695
4696
4697
4698
4699
4700
4701

4702
4703

4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716

4717
4718
4719

4720
4721
4722
4723
4724
4725
4726
....
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
....
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
....
6213
6214
6215
6216
6217
6218
6219
6220
6221











6222
6223
6224
6225
6226
6227
6228
....
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
....
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
	rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
					      const char *dst_path,
					      rl2CoveragePtr coverage,
					      double res, double minx,
					      double miny, double maxx,
					      double maxy, unsigned int width,
					      unsigned int height, int red_band,

					      int nir_band, int is_centered,
					      int decimal_digits);


    RL2_DECLARE int
	rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle,
						      int max_threads,
						      const char *dst_path,
						      rl2CoveragePtr coverage,
						      sqlite3_int64 section_id,
						      double res, double minx,
						      double miny, double maxx,
						      double maxy,
						      unsigned int width,
						      unsigned int height,
						      int red_band,

						      int nir_band,
						      int is_centered,
						      int decimal_digits);


    RL2_DECLARE int
	rl2_export_jpeg_from_dbms (sqlite3 * handle, int max_threads,
				   const char *dst_path,
				   rl2CoveragePtr coverage, double x_res,
				   double y_res, double minx, double miny,
				   double maxx, double maxy, unsigned int width,
................................................................................
 \note ownership of the rgba buffer will be definitely acquired by the 
 internal PDF writer.
 */
    RL2_DECLARE int
	rl2_rgba_to_pdf (const void *priv_data, unsigned int width,
			 unsigned int height, unsigned char *rgba,
			 unsigned char **pdf, int *pdf_size);
			 
			 
    RL2_DECLARE int
	rl2_rgba_to_pdfazzo (const void *priv_data, unsigned int width,
			 unsigned int height, unsigned char *rgba,
			 unsigned char **pdf, int *pdf_size);

/**
 Exports an all-Gray PDF document

 \param priv_data pointer to the opaque internal connection object 
 returned by a previous call to rl2_alloc_private() 
 \param width the PDF image width.
................................................................................
						     const char *db_prefix,
						     const char *cvg_name,
						     const unsigned char *blob,
						     int blob_sz,
						     int reaspect,
						     const char *style_name,
						     const unsigned char
						     *xml_style,
						     int *has_labels);

    RL2_DECLARE int rl2_map_image_paint_from_vector_ex (sqlite3 * sqlite,
							const void *data,
							rl2CanvasPtr canvas,
							const char *db_prefix,
							const char *cvg_name,
							const unsigned char
................................................................................
							const unsigned char
							*xml_style,
							int with_nodes,
							int with_edges_or_links,
							int with_faces,
							int
							with_edge_or_link_seeds,
							int with_face_seeds,
							int *has_labels);












    RL2_DECLARE unsigned char *rl2_map_image_from_wms (sqlite3 * sqlite,
						       const char *db_prefix,
						       const char *cvg_name,
						       const unsigned char
						       *blob, int blob_sz,
						       int width, int height,
................................................................................
						       const char *style,
						       const char *format,
						       int transparent,
						       const char *bg_color,
						       int *image_size);

    RL2_DECLARE int rl2_image_blob_from_map_config (sqlite3 * sqlite,
							   const void *data,
							   const char *mapconf,
							   const unsigned char
							   *blob, int blob_sz,
							   int width,
							   int height,
							   const char *format,
							   int quality,
							   int reaspect,
							   unsigned char **img,
							   int *img_size);

    RL2_DECLARE rl2FeatureTypeStylePtr rl2_feature_type_style_from_xml (const
									char
									*name,
									const
									unsigned
									char
................................................................................
					  double no_data_value,
					  double densify_dist,
					  double z_simplify_dist, int update_m);

    RL2_DECLARE int rl2_serialize_map_config (rl2MapConfigPtr map_config_obj,
					      unsigned char **blob,
					      int *blob_sz);
	
#ifdef _WIN32				      
	RL2_DECLARE FILE * rl2_win_fopen(const char *path, const char *mode);
#endif

#ifdef __cplusplus
}
#endif

#endif				/* _RASTERLITE2_H */







>
|
|
>













>


|
>







 







|
|


|
|







 







|
<







 







|
<
>
>
>
>
>
>
>
>
>
>
>







 







|
|
|
|
|
|
|
|
|
|
|







 







|
|
|







4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
....
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
....
6198
6199
6200
6201
6202
6203
6204
6205

6206
6207
6208
6209
6210
6211
6212
....
6216
6217
6218
6219
6220
6221
6222
6223

6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
....
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
....
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
	rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
					      const char *dst_path,
					      rl2CoveragePtr coverage,
					      double res, double minx,
					      double miny, double maxx,
					      double maxy, unsigned int width,
					      unsigned int height, int red_band,
					      int green_band, int nir_band,
					      int is_centered,
					      int decimal_digits,
					      int ndwi_mode);

    RL2_DECLARE int
	rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle,
						      int max_threads,
						      const char *dst_path,
						      rl2CoveragePtr coverage,
						      sqlite3_int64 section_id,
						      double res, double minx,
						      double miny, double maxx,
						      double maxy,
						      unsigned int width,
						      unsigned int height,
						      int red_band,
						      int green_band,
						      int nir_band,
						      int is_centered,
						      int decimal_digits,
						      int ndwi_mode);

    RL2_DECLARE int
	rl2_export_jpeg_from_dbms (sqlite3 * handle, int max_threads,
				   const char *dst_path,
				   rl2CoveragePtr coverage, double x_res,
				   double y_res, double minx, double miny,
				   double maxx, double maxy, unsigned int width,
................................................................................
 \note ownership of the rgba buffer will be definitely acquired by the 
 internal PDF writer.
 */
    RL2_DECLARE int
	rl2_rgba_to_pdf (const void *priv_data, unsigned int width,
			 unsigned int height, unsigned char *rgba,
			 unsigned char **pdf, int *pdf_size);


    RL2_DECLARE int
	rl2_rgba_to_pdfazzo (const void *priv_data, unsigned int width,
			     unsigned int height, unsigned char *rgba,
			     unsigned char **pdf, int *pdf_size);

/**
 Exports an all-Gray PDF document

 \param priv_data pointer to the opaque internal connection object 
 returned by a previous call to rl2_alloc_private() 
 \param width the PDF image width.
................................................................................
						     const char *db_prefix,
						     const char *cvg_name,
						     const unsigned char *blob,
						     int blob_sz,
						     int reaspect,
						     const char *style_name,
						     const unsigned char
						     *xml_style);


    RL2_DECLARE int rl2_map_image_paint_from_vector_ex (sqlite3 * sqlite,
							const void *data,
							rl2CanvasPtr canvas,
							const char *db_prefix,
							const char *cvg_name,
							const unsigned char
................................................................................
							const unsigned char
							*xml_style,
							int with_nodes,
							int with_edges_or_links,
							int with_faces,
							int
							with_edge_or_link_seeds,
							int with_face_seeds);


    RL2_DECLARE int rl2_map_image_paint_labels (sqlite3 * sqlite,
						const void *data,
						rl2CanvasPtr canvas,
						const char *db_prefix,
						const char *cvg_name,
						const unsigned char *blob,
						int blob_sz,
						int reaspect,
						const char *style_name,
						const unsigned char *xml_style);

    RL2_DECLARE unsigned char *rl2_map_image_from_wms (sqlite3 * sqlite,
						       const char *db_prefix,
						       const char *cvg_name,
						       const unsigned char
						       *blob, int blob_sz,
						       int width, int height,
................................................................................
						       const char *style,
						       const char *format,
						       int transparent,
						       const char *bg_color,
						       int *image_size);

    RL2_DECLARE int rl2_image_blob_from_map_config (sqlite3 * sqlite,
						    const void *data,
						    const char *mapconf,
						    const unsigned char
						    *blob, int blob_sz,
						    int width,
						    int height,
						    const char *format,
						    int quality,
						    int reaspect,
						    unsigned char **img,
						    int *img_size);

    RL2_DECLARE rl2FeatureTypeStylePtr rl2_feature_type_style_from_xml (const
									char
									*name,
									const
									unsigned
									char
................................................................................
					  double no_data_value,
					  double densify_dist,
					  double z_simplify_dist, int update_m);

    RL2_DECLARE int rl2_serialize_map_config (rl2MapConfigPtr map_config_obj,
					      unsigned char **blob,
					      int *blob_sz);

#ifdef _WIN32
    RL2_DECLARE FILE *rl2_win_fopen (const char *path, const char *mode);
#endif

#ifdef __cplusplus
}
#endif

#endif				/* _RASTERLITE2_H */

Changes to headers/rasterlite2/rl2graphics.h.

1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
....
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
....
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
....
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
	*rl2_graph_get_context_alpha_array (rl2GraphicsContextPtr context,
					    int *half_transparent);

/**
 Allocates and initializes a new Canvas object (generic Vector Layer)

 \param ref_ctx pointer to Graphics Context
 \param ref_ctx_labels pointer to Labels Graphics Context
 
 \return the pointer to newly created Canvas Object: NULL on failure.
 
 \sa rl2_destroy_canvas, rl2_create_topology_canvas, rl2_create_network_canvas, 
 rl2_create_raster_canves, rl2_create_wms_canvas, rl2_get_canvas_type,
 rl2_get_canvas_ctx, rl2_is_canvas_ready, rl2_is_canvas_error
 
 \note you are responsible to destroy (before or after) any allocated 
 Canvas object.
 */
    RL2_DECLARE rl2CanvasPtr rl2_create_vector_canvas (rl2GraphicsContextPtr
						       ref_ctx,
						       rl2GraphicsContextPtr
						       ref_ctx_labels);

/**
 Allocates and initializes a new Canvas object (Topology Layer)

 \param ref_ctx pointer to base Graphics Context
 \param ref_ctx_labels pointer to Labels Graphics Context
 \param ref_ctx_nodes pointer to Nodes Graphics Context (may be NULL)
 \param ref_ctx_edges pointer to Edges Graphics Context (may be NULL)
 \param ref_ctx_faces pointer to Faces Graphics Context (may be NULL)
 \param ref_ctx_edge_seeds pointer to Edge Seeds Graphics Context (may be NULL)
 \param ref_ctx_face_seeds pointer to Face Seeds Graphics Context (may be NULL)
 
 \return the pointer to newly created Canvas Object: NULL on failure.
................................................................................
 
 \note you are responsible to destroy (before or after) any allocated 
 Canvas object.
 */
    RL2_DECLARE rl2CanvasPtr rl2_create_topology_canvas (rl2GraphicsContextPtr
							 ref_ctx,
							 rl2GraphicsContextPtr
							 ref_ctx_labels,
							 rl2GraphicsContextPtr
							 ref_ctx_nodes,
							 rl2GraphicsContextPtr
							 ref_ctx_edges,
							 rl2GraphicsContextPtr
							 ref_ctx_faces,
							 rl2GraphicsContextPtr
							 ref_ctx_edge_seeds,
................................................................................
							 rl2GraphicsContextPtr
							 ref_ctx_face_seeds);

/**
 Allocates and initializes a new Canvas object (Topology Layer)

 \param ref_ctx pointer to base Graphics Context
 \param ref_ctx_labels pointer to Labels Graphics Context
 \param ref_ctx_nodes pointer to Nodes Graphics Context (may be NULL)
 \param ref_ctx_links pointer to Links Graphics Context (may be NULL)
 \param ref_ctx_link_seeds pointer to Link Seeds Graphics Context (may be NULL)
 
 \return the pointer to newly created Canvas Object: NULL on failure.
 
 \sa rl2_destroy_canvas, rl2_create_vector_canvas, rl2_create_topology_canvas, 
................................................................................
 rl2_get_canvas_ctx, rl2_is_canvas_ready, rl2_is_canvas_error
 
 \note you are responsible to destroy (before or after) any allocated 
 Canvas object.
 */
    RL2_DECLARE rl2CanvasPtr rl2_create_network_canvas (rl2GraphicsContextPtr
							ref_ctx,
							rl2GraphicsContextPtr
							ref_ctx_labels,
							rl2GraphicsContextPtr
							ref_ctx_nodes,
							rl2GraphicsContextPtr
							ref_ctx_links,
							rl2GraphicsContextPtr
							ref_ctx_link_seeds);








<











|
<
<





<







 







<
<







 







<







 







<
<







1704
1705
1706
1707
1708
1709
1710

1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722


1723
1724
1725
1726
1727

1728
1729
1730
1731
1732
1733
1734
....
1739
1740
1741
1742
1743
1744
1745


1746
1747
1748
1749
1750
1751
1752
....
1753
1754
1755
1756
1757
1758
1759

1760
1761
1762
1763
1764
1765
1766
....
1768
1769
1770
1771
1772
1773
1774


1775
1776
1777
1778
1779
1780
1781
	*rl2_graph_get_context_alpha_array (rl2GraphicsContextPtr context,
					    int *half_transparent);

/**
 Allocates and initializes a new Canvas object (generic Vector Layer)

 \param ref_ctx pointer to Graphics Context

 
 \return the pointer to newly created Canvas Object: NULL on failure.
 
 \sa rl2_destroy_canvas, rl2_create_topology_canvas, rl2_create_network_canvas, 
 rl2_create_raster_canves, rl2_create_wms_canvas, rl2_get_canvas_type,
 rl2_get_canvas_ctx, rl2_is_canvas_ready, rl2_is_canvas_error
 
 \note you are responsible to destroy (before or after) any allocated 
 Canvas object.
 */
    RL2_DECLARE rl2CanvasPtr rl2_create_vector_canvas (rl2GraphicsContextPtr
						       ref_ctx);



/**
 Allocates and initializes a new Canvas object (Topology Layer)

 \param ref_ctx pointer to base Graphics Context

 \param ref_ctx_nodes pointer to Nodes Graphics Context (may be NULL)
 \param ref_ctx_edges pointer to Edges Graphics Context (may be NULL)
 \param ref_ctx_faces pointer to Faces Graphics Context (may be NULL)
 \param ref_ctx_edge_seeds pointer to Edge Seeds Graphics Context (may be NULL)
 \param ref_ctx_face_seeds pointer to Face Seeds Graphics Context (may be NULL)
 
 \return the pointer to newly created Canvas Object: NULL on failure.
................................................................................
 
 \note you are responsible to destroy (before or after) any allocated 
 Canvas object.
 */
    RL2_DECLARE rl2CanvasPtr rl2_create_topology_canvas (rl2GraphicsContextPtr
							 ref_ctx,
							 rl2GraphicsContextPtr


							 ref_ctx_nodes,
							 rl2GraphicsContextPtr
							 ref_ctx_edges,
							 rl2GraphicsContextPtr
							 ref_ctx_faces,
							 rl2GraphicsContextPtr
							 ref_ctx_edge_seeds,
................................................................................
							 rl2GraphicsContextPtr
							 ref_ctx_face_seeds);

/**
 Allocates and initializes a new Canvas object (Topology Layer)

 \param ref_ctx pointer to base Graphics Context

 \param ref_ctx_nodes pointer to Nodes Graphics Context (may be NULL)
 \param ref_ctx_links pointer to Links Graphics Context (may be NULL)
 \param ref_ctx_link_seeds pointer to Link Seeds Graphics Context (may be NULL)
 
 \return the pointer to newly created Canvas Object: NULL on failure.
 
 \sa rl2_destroy_canvas, rl2_create_vector_canvas, rl2_create_topology_canvas, 
................................................................................
 rl2_get_canvas_ctx, rl2_is_canvas_ready, rl2_is_canvas_error
 
 \note you are responsible to destroy (before or after) any allocated 
 Canvas object.
 */
    RL2_DECLARE rl2CanvasPtr rl2_create_network_canvas (rl2GraphicsContextPtr
							ref_ctx,


							rl2GraphicsContextPtr
							ref_ctx_nodes,
							rl2GraphicsContextPtr
							ref_ctx_links,
							rl2GraphicsContextPtr
							ref_ctx_link_seeds);

Changes to headers/rasterlite2_private.h.

1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
....
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610

1611
1612
1613
1614
1615
1616
1617
....
1630
1631
1632
1633
1634
1635
1636




1637
1638
1639











1640
1641
1642
1643
1644
1645
1646
....
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
    } rl2TransformParams;
    typedef rl2TransformParams *rl2TransformParamsPtr;

    typedef struct rl2_priv_canvas
    {
	int type;
	void *ref_ctx;
	void *ref_ctx_labels;
	void *ref_ctx_nodes;
	void *ref_ctx_edges;
	void *ref_ctx_links;
	void *ref_ctx_faces;
	void *ref_ctx_edge_seeds;
	void *ref_ctx_link_seeds;
	void *ref_ctx_face_seeds;
	int ctx_ready;
	int ctx_labels_ready;
	int ctx_nodes_ready;
	int ctx_edges_ready;
	int ctx_links_ready;
	int ctx_faces_ready;
	int ctx_edge_seeds_ready;
	int ctx_link_seeds_ready;
	int ctx_face_seeds_ready;
................................................................................
	const char *prefix;
	double min_value;
	double max_value;
	char *style_name;
	char *xml_style;
	unsigned char syntetic_band;
	void *ctx;
	void *ctx_labels;
	void *ctx_nodes;
	void *ctx_edges;
	void *ctx_faces;
	void *ctx_edge_seeds;
	void *ctx_face_seeds;
	void *ctx_links;
	void *ctx_link_seeds;
	rl2CanvasPtr canvas;
	int valid;

	struct rl2_priv_map_layer *next;
    } rl2PrivMapLayer;
    typedef rl2PrivMapLayer *rl2PrivMapLayerPtr;

    typedef struct rl2_priv_map_config_aux
    {
	int valid;
................................................................................
	unsigned char *image;
	int image_size;
	rl2MapConfigPtr map_config;
	rl2PrivMapAttachedDbPtr first_db;
	rl2PrivMapAttachedDbPtr last_db;
	rl2PrivMapLayerPtr first_lyr;
	rl2PrivMapLayerPtr last_lyr;




    } rl2PrivMapConfigAux;
    typedef rl2PrivMapConfigAux *rl2PrivMapConfigAuxPtr;












    typedef struct rl2_wms_tile
    {
	int base_x;
	int base_y;
	int width;
	int height;
	double min_x;
................................................................................
				 int bytes);

    RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_null (const char
								*name);

    RL2_PRIVATE void rl2_destroy_variant_value (rl2PrivVariantValuePtr value);

    RL2_PRIVATE void rl2_draw_vector_feature (void *ctx, void *ctx_labels,
					      sqlite3 * handle,
					      const void *priv_data,
					      rl2VectorSymbolizerPtr symbolizer,
					      int height, double minx,
					      double miny, double maxx,
					      double maxy, double x_res,
					      double y_res, rl2GeometryPtr geom,
					      rl2VariantArrayPtr variant,
					      int *has_labels);

    RL2_PRIVATE rl2GeometryPtr
	rl2_geometry_from_blob (const unsigned char *blob, int blob_sz);

    RL2_PRIVATE int rl2_geometry_to_blob (rl2GeometryPtr geom,
					  unsigned char **blob, int *blob_sz);








<








<







 







<









>







 







>
>
>
>



>
>
>
>
>
>
>
>
>
>
>







 







|
<
|






|







1555
1556
1557
1558
1559
1560
1561

1562
1563
1564
1565
1566
1567
1568
1569

1570
1571
1572
1573
1574
1575
1576
....
1592
1593
1594
1595
1596
1597
1598

1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
....
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
....
2706
2707
2708
2709
2710
2711
2712
2713

2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
    } rl2TransformParams;
    typedef rl2TransformParams *rl2TransformParamsPtr;

    typedef struct rl2_priv_canvas
    {
	int type;
	void *ref_ctx;

	void *ref_ctx_nodes;
	void *ref_ctx_edges;
	void *ref_ctx_links;
	void *ref_ctx_faces;
	void *ref_ctx_edge_seeds;
	void *ref_ctx_link_seeds;
	void *ref_ctx_face_seeds;
	int ctx_ready;

	int ctx_nodes_ready;
	int ctx_edges_ready;
	int ctx_links_ready;
	int ctx_faces_ready;
	int ctx_edge_seeds_ready;
	int ctx_link_seeds_ready;
	int ctx_face_seeds_ready;
................................................................................
	const char *prefix;
	double min_value;
	double max_value;
	char *style_name;
	char *xml_style;
	unsigned char syntetic_band;
	void *ctx;

	void *ctx_nodes;
	void *ctx_edges;
	void *ctx_faces;
	void *ctx_edge_seeds;
	void *ctx_face_seeds;
	void *ctx_links;
	void *ctx_link_seeds;
	rl2CanvasPtr canvas;
	int valid;
	int has_labels;
	struct rl2_priv_map_layer *next;
    } rl2PrivMapLayer;
    typedef rl2PrivMapLayer *rl2PrivMapLayerPtr;

    typedef struct rl2_priv_map_config_aux
    {
	int valid;
................................................................................
	unsigned char *image;
	int image_size;
	rl2MapConfigPtr map_config;
	rl2PrivMapAttachedDbPtr first_db;
	rl2PrivMapAttachedDbPtr last_db;
	rl2PrivMapLayerPtr first_lyr;
	rl2PrivMapLayerPtr last_lyr;
	int has_labels;
	int update_labels;
	void *ctx_labels;
	rl2CanvasPtr canvas_labels;
    } rl2PrivMapConfigAux;
    typedef rl2PrivMapConfigAux *rl2PrivMapConfigAuxPtr;

    typedef struct rl2_aux_map_painter
    {
	void *opaque_thread_id;
	char layer_type;
	sqlite3 * sqlite;
	const void *data;
	rl2PrivMapLayerPtr aux_lyr;
	rl2PrivMapConfigAuxPtr aux;
    } rl2AuxMapPainter;
    typedef rl2AuxMapPainter *rl2AuxMapPainterPtr;

    typedef struct rl2_wms_tile
    {
	int base_x;
	int base_y;
	int width;
	int height;
	double min_x;
................................................................................
				 int bytes);

    RL2_PRIVATE rl2PrivVariantValuePtr rl2_create_variant_null (const char
								*name);

    RL2_PRIVATE void rl2_destroy_variant_value (rl2PrivVariantValuePtr value);

    RL2_PRIVATE void rl2_draw_vector_feature (void *ctx, 

					      sqlite3 * handle, const void *priv_data,
					      rl2VectorSymbolizerPtr symbolizer,
					      int height, double minx,
					      double miny, double maxx,
					      double maxy, double x_res,
					      double y_res, rl2GeometryPtr geom,
					      rl2VariantArrayPtr variant,
					      int mode_labels);

    RL2_PRIVATE rl2GeometryPtr
	rl2_geometry_from_blob (const unsigned char *blob, int blob_sz);

    RL2_PRIVATE int rl2_geometry_to_blob (rl2GeometryPtr geom,
					  unsigned char **blob, int *blob_sz);

Changes to src/rl2auxrender.c.

4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
....
4653
4654
4655
4656
4657
4658
4659


4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673


4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693

4694
4695
4696
4697
4698
4699
4700
	  item_in = item_in->next;
      }

    return out;
}

RL2_PRIVATE void
rl2_draw_vector_feature (void *p_ctx, void *p_ctx_labels, sqlite3 * handle,
			 const void *priv_data,
			 rl2VectorSymbolizerPtr symbolizer, int height,
			 double minx, double miny, double maxx, double maxy,
			 double x_res, double y_res, rl2GeometryPtr geom,
			 rl2VariantArrayPtr variant, int *has_labels)
{
/* drawing a vector feature on the current canvas */
    rl2PrivVectorSymbolizerItemPtr item;
    rl2GraphicsContextPtr ctx = (rl2GraphicsContextPtr) p_ctx;
    rl2GraphicsContextPtr ctx_labels = (rl2GraphicsContextPtr) p_ctx_labels;
    rl2PrivVectorSymbolizerPtr sym = (rl2PrivVectorSymbolizerPtr) symbolizer;
    rl2PrivVectorSymbolizerPtr default_symbolizer = NULL;
    rl2PrivVectorSymbolizerPtr dyn_symbolizer = NULL;

    *has_labels = 0;
    if (ctx == NULL || geom == NULL)
	return;

    if (sym != NULL)
      {
	  /* creating a dynamic symbolizer */
	  dyn_symbolizer =
................................................................................
	      default_symbolizer->first = item;
	  if (default_symbolizer->last != NULL)
	      default_symbolizer->last->next = item;
	  default_symbolizer->last = item;
	  sym = default_symbolizer;
      }



/* we'll render all geometries first */
    if (geom->first_polygon != NULL)
	draw_polygons (ctx, handle, sym, height, minx, miny, maxx, maxy,
		       x_res, y_res, geom);
    if (geom->first_linestring != NULL)
	draw_lines (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
		    y_res, geom);
    if (geom->first_point != NULL)
	draw_points (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
		     y_res, geom);

    if (sym != NULL && ctx_labels != NULL)
      {
	  /* then we'll render any eventual TextSymbolizer */


	  item = sym->first;
	  while (item != NULL)
	    {
		if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
		    && item->symbolizer != NULL)
		  {
		      rl2PrivTextSymbolizerPtr text =
			  (rl2PrivTextSymbolizerPtr) (item->symbolizer);
		      if (text->label != NULL)
			{
			    draw_labels (ctx_labels, handle,
					 priv_data, text, height,
					 minx, miny, maxx, maxy,
					 x_res, y_res, geom);
			    *has_labels = 1;
			}
		  }
		item = item->next;
	    }
      }


    if (default_symbolizer != NULL)
	rl2_destroy_vector_symbolizer (default_symbolizer);
    if (dyn_symbolizer != NULL)
	rl2_destroy_vector_symbolizer (dyn_symbolizer);
}








|
<



|




<




<







 







>
>
|









|
|
|
|
>
>










|



<





>







4550
4551
4552
4553
4554
4555
4556
4557

4558
4559
4560
4561
4562
4563
4564
4565

4566
4567
4568
4569

4570
4571
4572
4573
4574
4575
4576
....
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688

4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
	  item_in = item_in->next;
      }

    return out;
}

RL2_PRIVATE void
rl2_draw_vector_feature (void *p_ctx, sqlite3 * handle, const void *priv_data,

			 rl2VectorSymbolizerPtr symbolizer, int height,
			 double minx, double miny, double maxx, double maxy,
			 double x_res, double y_res, rl2GeometryPtr geom,
			 rl2VariantArrayPtr variant, int mode_labels)
{
/* drawing a vector feature on the current canvas */
    rl2PrivVectorSymbolizerItemPtr item;
    rl2GraphicsContextPtr ctx = (rl2GraphicsContextPtr) p_ctx;

    rl2PrivVectorSymbolizerPtr sym = (rl2PrivVectorSymbolizerPtr) symbolizer;
    rl2PrivVectorSymbolizerPtr default_symbolizer = NULL;
    rl2PrivVectorSymbolizerPtr dyn_symbolizer = NULL;


    if (ctx == NULL || geom == NULL)
	return;

    if (sym != NULL)
      {
	  /* creating a dynamic symbolizer */
	  dyn_symbolizer =
................................................................................
	      default_symbolizer->first = item;
	  if (default_symbolizer->last != NULL)
	      default_symbolizer->last->next = item;
	  default_symbolizer->last = item;
	  sym = default_symbolizer;
      }

if (!mode_labels)
{
	/* we'll render all geometries */
    if (geom->first_polygon != NULL)
	draw_polygons (ctx, handle, sym, height, minx, miny, maxx, maxy,
		       x_res, y_res, geom);
    if (geom->first_linestring != NULL)
	draw_lines (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
		    y_res, geom);
    if (geom->first_point != NULL)
	draw_points (ctx, handle, sym, height, minx, miny, maxx, maxy, x_res,
		     y_res, geom);
}
else
{
	  /* we'll render any eventual TextSymbolizer */
    if (sym != NULL)
      {
	  item = sym->first;
	  while (item != NULL)
	    {
		if (item->symbolizer_type == RL2_TEXT_SYMBOLIZER
		    && item->symbolizer != NULL)
		  {
		      rl2PrivTextSymbolizerPtr text =
			  (rl2PrivTextSymbolizerPtr) (item->symbolizer);
		      if (text->label != NULL)
			{
			    draw_labels (ctx, handle,
					 priv_data, text, height,
					 minx, miny, maxx, maxy,
					 x_res, y_res, geom);

			}
		  }
		item = item->next;
	    }
      }
  }

    if (default_symbolizer != NULL)
	rl2_destroy_vector_symbolizer (default_symbolizer);
    if (dyn_symbolizer != NULL)
	rl2_destroy_vector_symbolizer (dyn_symbolizer);
}

Changes to src/rl2dbms.c.

7988
7989
7990
7991
7992
7993
7994
7995

7996
7997
7998
7999
8000
8001
8002
....
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724


8725
8726
8727




8728
8729
8730
8731
8732
8733
8734
RL2_DECLARE int
rl2_get_raw_raster_data_transparent (sqlite3 * handle, int max_threads,
				     rl2CoveragePtr cvg, unsigned int width,
				     unsigned int height, double minx,
				     double miny, double maxx, double maxy,
				     double x_res, double y_res,
				     unsigned char **buffer, int *buf_size,
				     unsigned char **mask, int *mask_size, unsigned char syntetic_band,

				     rl2PalettePtr * palette,
				     unsigned char *out_pixel,
				     rl2PixelPtr no_data,
				     rl2RasterSymbolizerPtr style,
				     rl2RasterStatisticsPtr stats)
{
/*
................................................................................
		goto error;
	    }
      }
    sqlite3_finalize (stmt);
    stmt = NULL;

    if (name == NULL || xml == NULL)
      {
	  if (name != NULL)
	      free (name);
	  if (xml != NULL)
	      free (xml);
	  goto error;
      }
    stl = rl2_feature_type_style_from_xml (name, xml);
    if (stl == NULL)
	goto error;


    return stl;

  error:




    if (stmt != NULL)
	sqlite3_finalize (stmt);
    if (stl != NULL)
	rl2_destroy_feature_type_style (stl);
    return NULL;
}








|
>







 







<
<
<
<
<
|
<



>
>



>
>
>
>







7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
....
8709
8710
8711
8712
8713
8714
8715





8716

8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
RL2_DECLARE int
rl2_get_raw_raster_data_transparent (sqlite3 * handle, int max_threads,
				     rl2CoveragePtr cvg, unsigned int width,
				     unsigned int height, double minx,
				     double miny, double maxx, double maxy,
				     double x_res, double y_res,
				     unsigned char **buffer, int *buf_size,
				     unsigned char **mask, int *mask_size,
				     unsigned char syntetic_band,
				     rl2PalettePtr * palette,
				     unsigned char *out_pixel,
				     rl2PixelPtr no_data,
				     rl2RasterSymbolizerPtr style,
				     rl2RasterStatisticsPtr stats)
{
/*
................................................................................
		goto error;
	    }
      }
    sqlite3_finalize (stmt);
    stmt = NULL;

    if (name == NULL || xml == NULL)





	goto error;

    stl = rl2_feature_type_style_from_xml (name, xml);
    if (stl == NULL)
	goto error;
    free (name);
    free (xml);
    return stl;

  error:
    if (name != NULL)
	free (name);
    if (xml != NULL)
	free (xml);
    if (stmt != NULL)
	sqlite3_finalize (stmt);
    if (stl != NULL)
	rl2_destroy_feature_type_style (stl);
    return NULL;
}

Changes to src/rl2import.c.

5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
....
5333
5334
5335
5336
5337
5338
5339



































5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
....
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391


5392
5393


5394






5395
5396

5397
5398
5399
5400
5401
5402
5403
....
5418
5419
5420
5421
5422
5423
5424












5425
5426
5427
5428
5429
5430


5431
5432
5433
5434
5435
5436
5437
....
5470
5471
5472
5473
5474
5475
5476
5477
5478

5479
5480
5481
5482
5483
5484

5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
static float
compute_ndvi (void *pixels, unsigned char sample_type,
	      unsigned char num_bands, unsigned short width,
	      unsigned char red_band, unsigned char nir_band,
	      unsigned short row, unsigned short col,
	      rl2PrivPixelPtr in_no_data, float out_no_data)
{
/* computing a Normalized Difference Vegetaion Index -NDVI */
    float red;
    float nir;
    unsigned char *p8;
    unsigned short *p16;
    if (sample_type == RL2_SAMPLE_UINT16)
      {
	  /* UINT16 samples */
................................................................................
	  if (is_ndvi_nodata_u8 (in_no_data, p8))
	      return out_no_data;
	  red = *(p8 + red_band);
	  nir = *(p8 + nir_band);
      }
    return (nir - red) / (nir + red);
}




































static int
export_ndvi_ascii_grid_common (int by_section, sqlite3 * handle,
			       int max_threads, const char *dst_path,
			       rl2CoveragePtr cvg, sqlite3_int64 section_id,
			       double res, double minx, double miny,
			       double maxx, double maxy, unsigned int width,
			       unsigned int height, int red_band,
			       int nir_band, int is_centered,
			       int decimal_digits)
{
/* exporting an NDVI ASCII Grid common implementation */
    rl2PalettePtr palette = NULL;
    rl2PixelPtr in_no_data;
    rl2AsciiGridDestinationPtr ascii = NULL;
    unsigned char level;
    unsigned char scale;
................................................................................
	RL2_OK)
	goto error;
    in_no_data = rl2_get_coverage_no_data (cvg);

    if (pixel_type != RL2_PIXEL_MULTIBAND)
	goto error;

    if (red_band < 0 || red_band >= num_bands)
	goto error;



    if (nir_band < 0 || nir_band >= num_bands)
	goto error;









    if (red_band == nir_band)
	goto error;


    if (by_section)
      {
	  /* single Section */
	  if (rl2_get_section_raw_raster_data
	      (handle, max_threads, cvg, section_id, width, height, minx,
	       miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette,
................................................................................
    out_pixels_size = width * height * sizeof (float);
    out_pixels = malloc (out_pixels_size);
    if (out_pixels == NULL)
	goto error;
    po = (float *) out_pixels;
    for (row = 0; row < height; row++)
      {












	  /* computing NDVI */
	  for (col = 0; col < width; col++)
	      *po++ =
		  compute_ndvi (pixels, sample_type, num_bands, width,
				red_band, nir_band, row, col,
				(rl2PrivPixelPtr) in_no_data, out_no_data);


      }
    free (pixels);
    pixels = NULL;

    ascii =
	rl2_create_ascii_grid_destination (dst_path, width, height,
					   xx_res, minx, miny, is_centered,
................................................................................
RL2_DECLARE int
rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
				      const char *dst_path,
				      rl2CoveragePtr cvg, double res,
				      double minx, double miny, double maxx,
				      double maxy, unsigned int width,
				      unsigned int height, int red_band,
				      int nir_band, int is_centered,
				      int decimal_digits)

{
/* exporting an ASCII Grid from the DBMS into the file-system */
    return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path,
					  cvg, 0, res, minx, miny, maxx, maxy,
					  width, height, red_band, nir_band,
					  is_centered, decimal_digits);

}

RL2_DECLARE int
rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle,
					      int max_threads,
					      const char *dst_path,
					      rl2CoveragePtr cvg,
					      sqlite3_int64 section_id,
					      double res, double minx,
					      double miny, double maxx,
					      double maxy, unsigned int width,
					      unsigned int height,
					      int red_band, int nir_band,
					      int is_centered,
					      int decimal_digits)
{
/* exporting an ASCII Grid - Section */
    return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path,
					  cvg, section_id, res, minx, miny,
					  maxx, maxy, width, height, red_band,
					  nir_band, is_centered,
					  decimal_digits);
}

static int
export_jpeg_common (int by_section, sqlite3 * handle, int max_threads,
		    const char *dst_path, rl2CoveragePtr cvg,
		    sqlite3_int64 section_id, double x_res, double y_res,
		    double minx, double miny, double maxx, double maxy,







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








|
|







 







|
<
|
>
>
|
|
>
>
|
>
>
>
>
>
>
|
|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
>
>







 







|
|
>




|
|
>












|
|
|





|
|







5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
....
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
....
5417
5418
5419
5420
5421
5422
5423
5424

5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
....
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
....
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
static float
compute_ndvi (void *pixels, unsigned char sample_type,
	      unsigned char num_bands, unsigned short width,
	      unsigned char red_band, unsigned char nir_band,
	      unsigned short row, unsigned short col,
	      rl2PrivPixelPtr in_no_data, float out_no_data)
{
/* computing a Normalized Difference Vegetation Index -NDVI */
    float red;
    float nir;
    unsigned char *p8;
    unsigned short *p16;
    if (sample_type == RL2_SAMPLE_UINT16)
      {
	  /* UINT16 samples */
................................................................................
	  if (is_ndvi_nodata_u8 (in_no_data, p8))
	      return out_no_data;
	  red = *(p8 + red_band);
	  nir = *(p8 + nir_band);
      }
    return (nir - red) / (nir + red);
}

static float
compute_ndwi (void *pixels, unsigned char sample_type,
	      unsigned char num_bands, unsigned short width,
	      unsigned char green_band, unsigned char nir_band,
	      unsigned short row, unsigned short col,
	      rl2PrivPixelPtr in_no_data, float out_no_data)
{
/* computing a Normalized Difference Water Index -NDWI */
    float green;
    float nir;
    unsigned char *p8;
    unsigned short *p16;
    if (sample_type == RL2_SAMPLE_UINT16)
      {
	  /* UINT16 samples */
	  p16 = (unsigned short *) pixels;
	  p16 += (row * width * num_bands) + (col * num_bands);
	  if (is_ndvi_nodata_u16 (in_no_data, p16))
	      return out_no_data;
	  green = *(p16 + green_band);
	  nir = *(p16 + nir_band);
      }
    else
      {
	  /* assuming UINT8 samples */
	  p8 = (unsigned char *) pixels;
	  p8 += (row * width * num_bands) + (col * num_bands);
	  if (is_ndvi_nodata_u8 (in_no_data, p8))
	      return out_no_data;
	  green = *(p8 + green_band);
	  nir = *(p8 + nir_band);
      }
    return (green - nir) / (green + nir);
}

static int
export_ndvi_ascii_grid_common (int by_section, sqlite3 * handle,
			       int max_threads, const char *dst_path,
			       rl2CoveragePtr cvg, sqlite3_int64 section_id,
			       double res, double minx, double miny,
			       double maxx, double maxy, unsigned int width,
			       unsigned int height, int red_band,
			       int green_band, int nir_band, int is_centered,
			       int decimal_digits, int ndwi_mode)
{
/* exporting an NDVI ASCII Grid common implementation */
    rl2PalettePtr palette = NULL;
    rl2PixelPtr in_no_data;
    rl2AsciiGridDestinationPtr ascii = NULL;
    unsigned char level;
    unsigned char scale;
................................................................................
	RL2_OK)
	goto error;
    in_no_data = rl2_get_coverage_no_data (cvg);

    if (pixel_type != RL2_PIXEL_MULTIBAND)
	goto error;

    if (ndwi_mode)

      {
	  if (green_band < 0 || green_band >= num_bands)
	      goto error;
	  if (nir_band < 0 || nir_band >= num_bands)
	      goto error;
	  if (green_band == nir_band)
	      goto error;
      }
    else
      {
	  if (red_band < 0 || red_band >= num_bands)
	      goto error;
	  if (nir_band < 0 || nir_band >= num_bands)
	      goto error;
	  if (red_band == nir_band)
	      goto error;
      }

    if (by_section)
      {
	  /* single Section */
	  if (rl2_get_section_raw_raster_data
	      (handle, max_threads, cvg, section_id, width, height, minx,
	       miny, maxx, maxy, res, res, &pixels, &pixels_size, &palette,
................................................................................
    out_pixels_size = width * height * sizeof (float);
    out_pixels = malloc (out_pixels_size);
    if (out_pixels == NULL)
	goto error;
    po = (float *) out_pixels;
    for (row = 0; row < height; row++)
      {
	  if (ndwi_mode)
	    {
		/* computing NDWI */
		for (col = 0; col < width; col++)
		    *po++ =
			compute_ndwi (pixels, sample_type, num_bands, width,
				      green_band, nir_band, row, col,
				      (rl2PrivPixelPtr) in_no_data,
				      out_no_data);
	    }
	  else
	    {
		/* computing NDVI */
		for (col = 0; col < width; col++)
		    *po++ =
			compute_ndvi (pixels, sample_type, num_bands, width,
				      red_band, nir_band, row, col,
				      (rl2PrivPixelPtr) in_no_data,
				      out_no_data);
	    }
      }
    free (pixels);
    pixels = NULL;

    ascii =
	rl2_create_ascii_grid_destination (dst_path, width, height,
					   xx_res, minx, miny, is_centered,
................................................................................
RL2_DECLARE int
rl2_export_ndvi_ascii_grid_from_dbms (sqlite3 * handle, int max_threads,
				      const char *dst_path,
				      rl2CoveragePtr cvg, double res,
				      double minx, double miny, double maxx,
				      double maxy, unsigned int width,
				      unsigned int height, int red_band,
				      int green_band, int nir_band,
				      int is_centered, int decimal_digits,
				      int ndwi_mode)
{
/* exporting an ASCII Grid from the DBMS into the file-system */
    return export_ndvi_ascii_grid_common (0, handle, max_threads, dst_path,
					  cvg, 0, res, minx, miny, maxx, maxy,
					  width, height, red_band, green_band,
					  nir_band, is_centered, decimal_digits,
					  ndwi_mode);
}

RL2_DECLARE int
rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite3 * handle,
					      int max_threads,
					      const char *dst_path,
					      rl2CoveragePtr cvg,
					      sqlite3_int64 section_id,
					      double res, double minx,
					      double miny, double maxx,
					      double maxy, unsigned int width,
					      unsigned int height,
					      int red_band, int green_band,
					      int nir_band, int is_centered,
					      int decimal_digits, int ndwi_mode)
{
/* exporting an ASCII Grid - Section */
    return export_ndvi_ascii_grid_common (1, handle, max_threads, dst_path,
					  cvg, section_id, res, minx, miny,
					  maxx, maxy, width, height, red_band,
					  green_band, nir_band, is_centered,
					  decimal_digits, ndwi_mode);
}

static int
export_jpeg_common (int by_section, sqlite3 * handle, int max_threads,
		    const char *dst_path, rl2CoveragePtr cvg,
		    sqlite3_int64 section_id, double x_res, double y_res,
		    double minx, double miny, double maxx, double maxy,

Changes to src/rl2map_config.c.

2339
2340
2341
2342
2343
2344
2345
2346

2347
2348
2349
2350
2351
2352
2353
....
3423
3424
3425
3426
3427
3428
3429
3430
3431

3432
3433
3434
3435
3436
3437
3438

3439
3440
3441
3442

3443
3444
3445
3446
3447
3448
3449
....
3498
3499
3500
3501
3502
3503
3504
3505
3506

3507
3508
3509
3510
3511
3512
3513
....
3514
3515
3516
3517
3518
3519
3520
3521
3522

3523
3524
3525
3526
3527
3528
3529
....
3693
3694
3695
3696
3697
3698
3699
3700
3701

3702
3703
3704
3705
3706
3707
3708

3709
3710
3711
3712

3713
3714
3715
3716
3717
3718
3719
....
3752
3753
3754
3755
3756
3757
3758
3759
3760

3761
3762
3763
3764
3765
3766
3767
....
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174

4175
4176
4177
4178
4179
4180
4181
....
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
....
7621
7622
7623
7624
7625
7626
7627




7628
7629
7630
7631
7632
7633
7634
....
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734

7735
7736
7737
7738
7739
7740
7741
....
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
....
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
....
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
....
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917

7918

7919
7920
7921
7922
7923
7924
7925
7926
....
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
....
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
....
8044
8045
8046
8047
8048
8049
8050
8051




8052
8053
						      {
							  unsigned char red;
							  unsigned char green;
							  unsigned char blue;
							  const char *value =
							      (const char
							       *)
							      (grandchild2->content);

							  if (parse_hex_color
							      (value, &red,
							       &green, &blue))
							      do_add_graphic_fill_color
								  (graphic, red,
								   green, blue);
						      }
................................................................................
		      xmlNode *text = attr->children;
		      if (text != NULL)
			{
			    int len;
			    const char *name;
			    if (text->type == XML_TEXT_NODE)
				name = (const char *) (text->content);
			    if (lyr->topology_internal_style->
				style_internal_name != NULL)

				free (lyr->topology_internal_style->
				      style_internal_name);
			    lyr->topology_internal_style->style_internal_name =
				NULL;
			    if (name != NULL)
			      {
				  len = strlen (name);

				  lyr->topology_internal_style->
				      style_internal_name = malloc (len + 1);
				  strcpy (lyr->topology_internal_style->
					  style_internal_name, name);

			      }
			}
		  }
		if (strcmp (name, "ShowFaces") == 0)
		  {
		      xmlNode *text = attr->children;
		      lyr->topology_internal_style->show_faces = 0;
................................................................................
		      if (text != NULL)
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  if (strcmp
				      ((const char *) (text->content),
				       "true") == 0)
				      lyr->topology_internal_style->
					  show_edge_seeds = 1;

			      }
			}
		  }
		if (strcmp (name, "ShowFaceSeeds") == 0)
		  {
		      xmlNode *text = attr->children;
		      lyr->topology_internal_style->show_face_seeds = 0;
................................................................................
		      if (text != NULL)
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  if (strcmp
				      ((const char *) (text->content),
				       "true") == 0)
				      lyr->topology_internal_style->
					  show_face_seeds = 1;

			      }
			}
		  }
	    }
	  attr = attr->next;
      }
}
................................................................................
		      xmlNode *text = attr->children;
		      if (text != NULL)
			{
			    int len;
			    const char *name;
			    if (text->type == XML_TEXT_NODE)
				name = (const char *) (text->content);
			    if (lyr->network_internal_style->
				style_internal_name != NULL)

				free (lyr->network_internal_style->
				      style_internal_name);
			    lyr->network_internal_style->style_internal_name =
				NULL;
			    if (name != NULL)
			      {
				  len = strlen (name);

				  lyr->network_internal_style->
				      style_internal_name = malloc (len + 1);
				  strcpy (lyr->network_internal_style->
					  style_internal_name, name);

			      }
			}
		  }
		if (strcmp (name, "ShowLinks") == 0)
		  {
		      xmlNode *text = attr->children;
		      lyr->network_internal_style->show_links = 0;
................................................................................
		      if (text != NULL)
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  if (strcmp
				      ((const char *) (text->content),
				       "true") == 0)
				      lyr->network_internal_style->
					  show_link_seeds = 1;

			      }
			}
		  }
	    }
	  attr = attr->next;
      }
}
................................................................................
			      {
				  value = (const char *) (text->content);
				  if (value == NULL)
				    {
					if (lyr->wms_style->background_color !=
					    NULL)
					  {
					      free (lyr->wms_style->
						    background_color);
					      lyr->wms_style->background_color =
						  NULL;
					  }
				    }
				  else
				    {
					if (lyr->wms_style->background_color !=
					    NULL)
					    free (lyr->wms_style->
						  background_color);
					len = strlen (value);
					lyr->wms_style->background_color =
					    malloc (len + 1);
					strcpy (lyr->wms_style->
						background_color, value);

				    }
			      }
			    text = text->next;
			}
		  }
		if (strcmp (name, "HttpProxy") == 0)
		    parse_http_proxy (node, lyr->wms_style);
................................................................................
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  value = (const char *) (text->content);
				  if (value != NULL)
				    {
					if (strcmp (value, "true") == 0)
					    map_config->map_background_transparent
						= 1;
				    }
			      }
			}
		  }
		attr = attr->next;
	    }
      }
................................................................................
    aux->ctx = NULL;
    aux->image = NULL;
    aux->image_size = 0;
    aux->first_db = NULL;
    aux->last_db = NULL;
    aux->first_lyr = NULL;
    aux->last_lyr = NULL;




    if (strcmp (format, "image/png") == 0)
      {
	  format_id = RL2_OUTPUT_FORMAT_PNG;
	  ok_format = 1;
      }
    if (strcmp (format, "image/jpeg") == 0)
      {
................................................................................
	  aux_lyr->layer = lyr;
	  aux_lyr->min_value = 0.0;
	  aux_lyr->max_value = 0.0;
	  aux_lyr->style_name = NULL;
	  aux_lyr->xml_style = NULL;
	  aux_lyr->syntetic_band = RL2_SYNTETIC_NONE;
	  aux_lyr->ctx = NULL;
	  aux_lyr->ctx_labels = NULL;
	  aux_lyr->ctx_nodes = NULL;
	  aux_lyr->ctx_edges = NULL;
	  aux_lyr->ctx_faces = NULL;
	  aux_lyr->ctx_edge_seeds = NULL;
	  aux_lyr->ctx_face_seeds = NULL;
	  aux_lyr->ctx_links = NULL;
	  aux_lyr->ctx_link_seeds = NULL;
	  aux_lyr->canvas = NULL;
	  aux_lyr->valid = lyr->visible;

	  aux_lyr->next = NULL;

	  if (aux->first_lyr == NULL)
	      aux->first_lyr = aux_lyr;
	  if (aux->last_lyr != NULL)
	      aux->last_lyr->next = aux_lyr;
	  aux->last_lyr = aux_lyr;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_vector (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating a Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_labels =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_labels != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_labels, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_vector_canvas (aux_lyr->ctx,
							  aux_lyr->ctx_labels);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_vector_view (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating a Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_labels =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_labels != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_labels, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_vector_canvas (aux_lyr->ctx,
							  aux_lyr->ctx_labels);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_vector_virtual (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating a Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_labels =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_labels != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_labels, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_vector_canvas (aux_lyr->ctx,
							  aux_lyr->ctx_labels);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_topology (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating all Topology Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_labels =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_nodes =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_edges =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_faces =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_edge_seeds =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_face_seeds =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_labels != NULL
			  && aux_lyr->ctx_nodes != NULL
			  && aux_lyr->ctx_edges != NULL
			  && aux_lyr->ctx_faces != NULL
			  && aux_lyr->ctx_edge_seeds != NULL
			  && aux_lyr->ctx_face_seeds != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_labels, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_nodes, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_edges, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_faces, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_edge_seeds, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_face_seeds, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_topology_canvas (aux_lyr->ctx,
							    aux_lyr->ctx_labels,
							    aux_lyr->ctx_nodes,
							    aux_lyr->ctx_edges,
							    aux_lyr->ctx_faces,

							    aux_lyr->ctx_edge_seeds,

							    aux_lyr->ctx_face_seeds);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_network (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating all Network Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_labels =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_nodes =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_links =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_link_seeds =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_labels != NULL
			  && aux_lyr->ctx_nodes != NULL
			  && aux_lyr->ctx_links != NULL
			  && aux_lyr->ctx_link_seeds != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_labels, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_nodes, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_links, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_link_seeds, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_network_canvas (aux_lyr->ctx,
							   aux_lyr->ctx_labels,
							   aux_lyr->ctx_nodes,
							   aux_lyr->ctx_links,
							   aux_lyr->ctx_link_seeds);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
	      free (lyr->style_name);
	  if (lyr->xml_style != NULL)
	      sqlite3_free (lyr->xml_style);
	  if (lyr->canvas != NULL)
	      rl2_destroy_canvas (lyr->canvas);
	  if (lyr->ctx != NULL)
	      rl2_graph_destroy_context (lyr->ctx);
	  if (lyr->ctx_labels != NULL)
	      rl2_graph_destroy_context (lyr->ctx_labels);
	  if (lyr->ctx_nodes != NULL)
	      rl2_graph_destroy_context (lyr->ctx_nodes);
	  if (lyr->ctx_edges != NULL)
	      rl2_graph_destroy_context (lyr->ctx_edges);
	  if (lyr->ctx_faces != NULL)
	      rl2_graph_destroy_context (lyr->ctx_faces);
	  if (lyr->ctx_edge_seeds != NULL)
................................................................................
	  if (lyr->ctx_link_seeds != NULL)
	      rl2_graph_destroy_context (lyr->ctx_link_seeds);
	  free (lyr);
	  lyr = lyr_n;
      }

    if (aux->ctx != NULL)
	rl2_graph_destroy_context (aux->ctx);




    free (aux);
}







|
>







 







|
|
>
|
|





>
|
|
|
|
>







 







|
|
>







 







|
|
>







 







|
|
>
|
|





>
|
|
|
|
>







 







|
|
>







 







|
|








|
|



|
|
>







 







|
|







 







>
>
>
>







 







<









>







 







<
<
|


<

|
<







 







<
<
|


<

|
<







 







<
<
|


<

|
<







 







<
<










|
<






<







<



>
|
>
|







 







<
<






|
<




<





|
|
|
|







 







<
<







 







|
>
>
>
>


2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
....
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
....
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
....
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
....
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
....
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
....
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
....
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
....
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
....
7733
7734
7735
7736
7737
7738
7739

7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
....
7822
7823
7824
7825
7826
7827
7828


7829
7830
7831

7832
7833

7834
7835
7836
7837
7838
7839
7840
....
7842
7843
7844
7845
7846
7847
7848


7849
7850
7851

7852
7853

7854
7855
7856
7857
7858
7859
7860
....
7862
7863
7864
7865
7866
7867
7868


7869
7870
7871

7872
7873

7874
7875
7876
7877
7878
7879
7880
....
7882
7883
7884
7885
7886
7887
7888


7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899

7900
7901
7902
7903
7904
7905

7906
7907
7908
7909
7910
7911
7912

7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
....
7928
7929
7930
7931
7932
7933
7934


7935
7936
7937
7938
7939
7940
7941

7942
7943
7944
7945

7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
....
8019
8020
8021
8022
8023
8024
8025


8026
8027
8028
8029
8030
8031
8032
....
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
						      {
							  unsigned char red;
							  unsigned char green;
							  unsigned char blue;
							  const char *value =
							      (const char
							       *)
							      (grandchild2->
							       content);
							  if (parse_hex_color
							      (value, &red,
							       &green, &blue))
							      do_add_graphic_fill_color
								  (graphic, red,
								   green, blue);
						      }
................................................................................
		      xmlNode *text = attr->children;
		      if (text != NULL)
			{
			    int len;
			    const char *name;
			    if (text->type == XML_TEXT_NODE)
				name = (const char *) (text->content);
			    if (lyr->
				topology_internal_style->style_internal_name !=
				NULL)
				free (lyr->
				      topology_internal_style->style_internal_name);
			    lyr->topology_internal_style->style_internal_name =
				NULL;
			    if (name != NULL)
			      {
				  len = strlen (name);
				  lyr->
				      topology_internal_style->style_internal_name
				      = malloc (len + 1);
				  strcpy (lyr->
					  topology_internal_style->style_internal_name,
					  name);
			      }
			}
		  }
		if (strcmp (name, "ShowFaces") == 0)
		  {
		      xmlNode *text = attr->children;
		      lyr->topology_internal_style->show_faces = 0;
................................................................................
		      if (text != NULL)
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  if (strcmp
				      ((const char *) (text->content),
				       "true") == 0)
				      lyr->
					  topology_internal_style->show_edge_seeds
					  = 1;
			      }
			}
		  }
		if (strcmp (name, "ShowFaceSeeds") == 0)
		  {
		      xmlNode *text = attr->children;
		      lyr->topology_internal_style->show_face_seeds = 0;
................................................................................
		      if (text != NULL)
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  if (strcmp
				      ((const char *) (text->content),
				       "true") == 0)
				      lyr->
					  topology_internal_style->show_face_seeds
					  = 1;
			      }
			}
		  }
	    }
	  attr = attr->next;
      }
}
................................................................................
		      xmlNode *text = attr->children;
		      if (text != NULL)
			{
			    int len;
			    const char *name;
			    if (text->type == XML_TEXT_NODE)
				name = (const char *) (text->content);
			    if (lyr->
				network_internal_style->style_internal_name !=
				NULL)
				free (lyr->
				      network_internal_style->style_internal_name);
			    lyr->network_internal_style->style_internal_name =
				NULL;
			    if (name != NULL)
			      {
				  len = strlen (name);
				  lyr->
				      network_internal_style->style_internal_name
				      = malloc (len + 1);
				  strcpy (lyr->
					  network_internal_style->style_internal_name,
					  name);
			      }
			}
		  }
		if (strcmp (name, "ShowLinks") == 0)
		  {
		      xmlNode *text = attr->children;
		      lyr->network_internal_style->show_links = 0;
................................................................................
		      if (text != NULL)
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  if (strcmp
				      ((const char *) (text->content),
				       "true") == 0)
				      lyr->
					  network_internal_style->show_link_seeds
					  = 1;
			      }
			}
		  }
	    }
	  attr = attr->next;
      }
}
................................................................................
			      {
				  value = (const char *) (text->content);
				  if (value == NULL)
				    {
					if (lyr->wms_style->background_color !=
					    NULL)
					  {
					      free (lyr->
						    wms_style->background_color);
					      lyr->wms_style->background_color =
						  NULL;
					  }
				    }
				  else
				    {
					if (lyr->wms_style->background_color !=
					    NULL)
					    free (lyr->
						  wms_style->background_color);
					len = strlen (value);
					lyr->wms_style->background_color =
					    malloc (len + 1);
					strcpy (lyr->
						wms_style->background_color,
						value);
				    }
			      }
			    text = text->next;
			}
		  }
		if (strcmp (name, "HttpProxy") == 0)
		    parse_http_proxy (node, lyr->wms_style);
................................................................................
			{
			    if (text->type == XML_TEXT_NODE)
			      {
				  value = (const char *) (text->content);
				  if (value != NULL)
				    {
					if (strcmp (value, "true") == 0)
					    map_config->
						map_background_transparent = 1;
				    }
			      }
			}
		  }
		attr = attr->next;
	    }
      }
................................................................................
    aux->ctx = NULL;
    aux->image = NULL;
    aux->image_size = 0;
    aux->first_db = NULL;
    aux->last_db = NULL;
    aux->first_lyr = NULL;
    aux->last_lyr = NULL;
    aux->has_labels = 0;
    aux->update_labels = 0;
    aux->ctx_labels = NULL;
    aux->canvas_labels = NULL;
    if (strcmp (format, "image/png") == 0)
      {
	  format_id = RL2_OUTPUT_FORMAT_PNG;
	  ok_format = 1;
      }
    if (strcmp (format, "image/jpeg") == 0)
      {
................................................................................
	  aux_lyr->layer = lyr;
	  aux_lyr->min_value = 0.0;
	  aux_lyr->max_value = 0.0;
	  aux_lyr->style_name = NULL;
	  aux_lyr->xml_style = NULL;
	  aux_lyr->syntetic_band = RL2_SYNTETIC_NONE;
	  aux_lyr->ctx = NULL;

	  aux_lyr->ctx_nodes = NULL;
	  aux_lyr->ctx_edges = NULL;
	  aux_lyr->ctx_faces = NULL;
	  aux_lyr->ctx_edge_seeds = NULL;
	  aux_lyr->ctx_face_seeds = NULL;
	  aux_lyr->ctx_links = NULL;
	  aux_lyr->ctx_link_seeds = NULL;
	  aux_lyr->canvas = NULL;
	  aux_lyr->valid = lyr->visible;
	  aux_lyr->has_labels = 0;
	  aux_lyr->next = NULL;

	  if (aux->first_lyr == NULL)
	      aux->first_lyr = aux_lyr;
	  if (aux->last_lyr != NULL)
	      aux->last_lyr->next = aux_lyr;
	  aux->last_lyr = aux_lyr;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_vector (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating a Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);


		      if (aux_lyr->ctx != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */

			    aux_lyr->canvas =
				rl2_create_vector_canvas (aux_lyr->ctx);

			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_vector_view (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating a Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);


		      if (aux_lyr->ctx != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */

			    aux_lyr->canvas =
				rl2_create_vector_canvas (aux_lyr->ctx);

			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_vector_virtual (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating a Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);


		      if (aux_lyr->ctx != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */

			    aux_lyr->canvas =
				rl2_create_vector_canvas (aux_lyr->ctx);

			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_topology (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating all Topology Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);


		      aux_lyr->ctx_nodes =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_edges =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_faces =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_edge_seeds =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_face_seeds =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_nodes != NULL

			  && aux_lyr->ctx_edges != NULL
			  && aux_lyr->ctx_faces != NULL
			  && aux_lyr->ctx_edge_seeds != NULL
			  && aux_lyr->ctx_face_seeds != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */

			    rl2_prime_background (aux_lyr->ctx_nodes, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_edges, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_faces, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_edge_seeds, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_face_seeds, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_topology_canvas (aux_lyr->ctx,

							    aux_lyr->ctx_nodes,
							    aux_lyr->ctx_edges,
							    aux_lyr->ctx_faces,
							    aux_lyr->
							    ctx_edge_seeds,
							    aux_lyr->
							    ctx_face_seeds);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
		if (do_check_prefix (aux, aux_lyr->layer->prefix, &alias))
		    do_check_layer_network (sqlite, alias, aux_lyr);
		if (aux_lyr->valid)
		  {
		      /* creating all Network Canvas */
		      aux_lyr->ctx =
			  rl2_graph_create_context (data, width, height);


		      aux_lyr->ctx_nodes =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_links =
			  rl2_graph_create_context (data, width, height);
		      aux_lyr->ctx_link_seeds =
			  rl2_graph_create_context (data, width, height);
		      if (aux_lyr->ctx != NULL && aux_lyr->ctx_nodes != NULL

			  && aux_lyr->ctx_links != NULL
			  && aux_lyr->ctx_link_seeds != NULL)
			{
			    rl2_prime_background (aux_lyr->ctx, 0, 0, 0, 0);	/* transparent background */

			    rl2_prime_background (aux_lyr->ctx_nodes, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_links, 0, 0, 0, 0);	/* transparent background */
			    rl2_prime_background (aux_lyr->ctx_link_seeds, 0, 0, 0, 0);	/* transparent background */
			    aux_lyr->canvas =
				rl2_create_network_canvas (aux_lyr->ctx,
							   aux_lyr->ctx_nodes,
							   aux_lyr->ctx_links,
							   aux_lyr->
							   ctx_link_seeds);
			}
		      if (aux_lyr->canvas == NULL)
			  aux_lyr->valid = 0;
		      if (aux_lyr->canvas == NULL)
			  goto error;
		  }
		break;
................................................................................
	      free (lyr->style_name);
	  if (lyr->xml_style != NULL)
	      sqlite3_free (lyr->xml_style);
	  if (lyr->canvas != NULL)
	      rl2_destroy_canvas (lyr->canvas);
	  if (lyr->ctx != NULL)
	      rl2_graph_destroy_context (lyr->ctx);


	  if (lyr->ctx_nodes != NULL)
	      rl2_graph_destroy_context (lyr->ctx_nodes);
	  if (lyr->ctx_edges != NULL)
	      rl2_graph_destroy_context (lyr->ctx_edges);
	  if (lyr->ctx_faces != NULL)
	      rl2_graph_destroy_context (lyr->ctx_faces);
	  if (lyr->ctx_edge_seeds != NULL)
................................................................................
	  if (lyr->ctx_link_seeds != NULL)
	      rl2_graph_destroy_context (lyr->ctx_link_seeds);
	  free (lyr);
	  lyr = lyr_n;
      }

    if (aux->ctx != NULL)
		rl2_graph_destroy_context (aux->ctx);
    if (aux->canvas_labels != NULL)
		rl2_destroy_canvas (aux->canvas_labels);
    if (aux->ctx_labels != NULL)
		rl2_graph_destroy_context (aux->ctx_labels);
    free (aux);
}

Changes to src/rl2map_config_paint.c.

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

119

120

121
122
123

124
125


126

127



128



129



130
131


132
133

134
135
136
137
138

139

140

141
142
143

144
145


146

147



148



149
150
151
152
153
154
155
156
157

158

159

160
161
162

163
164
165

166
167
168
169
170
171
172
173
174
175




















































176
177
178
179
180
181
182
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
...
523
524
525
526
527
528
529





























530
531
532
533
534
535
536
...
539
540
541
542
543
544
545


546
547
548






















549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564


565
566
567
568
569
570
571






































572
573
574
575
576
577
578
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;
	  if (ret == SQLITE_ROW)
	    {
		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
		  {
		      int hasLabels;
		      unsigned char *blob =
			  (unsigned char *) sqlite3_column_blob (stmt, 0);
		      int blob_sz = sqlite3_column_bytes (stmt, 0);
		      if (aux_lyr->layer->type == RL2_MAP_LAYER_TOPOLOGY)
			  ret =
			      rl2_map_image_paint_from_vector_ex (sqlite, data,
								  (rl2CanvasPtr)
								  aux_lyr->canvas,

								  aux_lyr->prefix,

								  aux_lyr->layer->

								  name, blob,
								  blob_sz, 0,
								  aux_lyr->

								  style_name,
								  (unsigned char


								   *) aux_lyr->

								  xml_style,



								  aux_lyr->layer->topology_style->show_nodes,



								  aux_lyr->layer->topology_style->show_edges,



								  aux_lyr->layer->topology_style->show_faces,
								  aux_lyr->layer->topology_style->show_edge_seeds,


								  aux_lyr->layer->topology_style->show_face_seeds,
								  &hasLabels);

		      else if (aux_lyr->layer->type == RL2_MAP_LAYER_NETWORK)
			  ret =
			      rl2_map_image_paint_from_vector_ex (sqlite, data,
								  (rl2CanvasPtr)
								  aux_lyr->canvas,

								  aux_lyr->prefix,

								  aux_lyr->layer->

								  name, blob,
								  blob_sz, 0,
								  aux_lyr->

								  style_name,
								  (unsigned char


								   *) aux_lyr->

								  xml_style,



								  aux_lyr->layer->network_style->show_nodes,



								  aux_lyr->layer->network_style->show_links,
								  0,
								  aux_lyr->layer->network_style->show_link_seeds,
								  0,
								  &hasLabels);
		      else
			  ret = rl2_map_image_paint_from_vector (sqlite, data,
								 (rl2CanvasPtr)
								 aux_lyr->canvas,

								 aux_lyr->prefix,

								 aux_lyr->layer->

								 name, blob,
								 blob_sz, 0,
								 aux_lyr->

								 style_name,
								 (unsigned char
								  *) aux_lyr->

								 xml_style,
								 &hasLabels);
		      if (ret == RL2_OK)
			  ret = rl2_graph_merge (aux->ctx, aux_lyr->ctx);
		      //if (hasLabels)
		      //  layer->SetLabels(true);
		      //if (quickStyle != NULL)
		      //free (quickStyle);
		      //layer->Validate(canvas);
		      //rl2_destroy_canvas(canvas);




















































		  }
	    }
      }
    sqlite3_finalize (stmt);
}

static void
................................................................................
							   aux_lyr->canvas,
							   aux_lyr->prefix,
							   aux_lyr->layer->name,
							   blob, blob_sz,
							   aux_lyr->style_name,
							   (unsigned char *)
							   aux_lyr->xml_style,
							   aux_lyr->
							   syntetic_band);
		      if (ret == RL2_OK)
			  ret = rl2_graph_merge (aux->ctx, aux_lyr->ctx);
		  }
	    }
      }
    sqlite3_finalize (stmt);
}
................................................................................
	  if (aux->ctx != NULL && ctx_in != NULL)
	      rl2_graph_merge (aux->ctx, ctx_in);
	  if (ctx_in)
	      rl2_graph_destroy_context (ctx_in);
	  free (rgba);
      }
}






























RL2_PRIVATE int
rl2_paint_map_config_aux (sqlite3 * sqlite, const void *data,
			  rl2PrivMapConfigAuxPtr aux)
{
/* rendering a full MapConfiguration */
    rl2PrivMapLayerPtr aux_lyr;
................................................................................
    int half_transparent;
    unsigned char *image = NULL;
    int image_size;

    if (aux == NULL)
	return RL2_ERROR;



    aux_lyr = aux->first_lyr;
    while (aux_lyr != NULL)
      {






















	  if (aux_lyr->valid)
	    {
		switch (aux_lyr->layer->type)
		  {
		  case RL2_MAP_LAYER_WMS:
		      do_paint_layer_wms (data, aux_lyr, aux);
		      break;
		  case RL2_MAP_LAYER_RASTER:
		      do_paint_layer_raster (sqlite, data, aux_lyr, aux);
		      break;
		  case RL2_MAP_LAYER_VECTOR:
		  case RL2_MAP_LAYER_VECTOR_VIEW:
		  case RL2_MAP_LAYER_VECTOR_VIRTUAL:
		  case RL2_MAP_LAYER_TOPOLOGY:
		  case RL2_MAP_LAYER_NETWORK:
		      do_paint_layer_vector (sqlite, data, aux_lyr, aux);


		      break;
		  default:
		      break;
		  };
	    }
	  aux_lyr = aux_lyr->next;
      }







































/* preparing the full rendered Map Image */
    rgb = rl2_graph_get_context_rgb_array (aux->ctx);
    alpha = rl2_graph_get_context_alpha_array (aux->ctx, &half_transparent);
    if (rgb == NULL || alpha == NULL)
	goto error;








<







|
>
|
>
|
>
|
<
<
>
|

>
>
|
>
|
>
>
>
|
>
>
>
|
>
>
>
|
|
>
>
|
<
>




|
>
|
>
|
>
|
<
<
>
|

>
>
|
>
|
>
>
>
|
>
>
>
|
<
|
|
<



|
>
|
>
|
>
|
<
<
>
|

<
>
|
<


<
<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







103
104
105
106
107
108
109

110
111
112
113
114
115
116
117
118
119
120
121
122
123


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
156
157
158
159


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

176
177

178
179
180
181
182
183
184
185
186
187


188
189
190

191
192

193
194






195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
...
293
294
295
296
297
298
299

300
301
302
303
304
305
306
307
...
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
...
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;
	  if (ret == SQLITE_ROW)
	    {
		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
		  {

		      unsigned char *blob =
			  (unsigned char *) sqlite3_column_blob (stmt, 0);
		      int blob_sz = sqlite3_column_bytes (stmt, 0);
		      if (aux_lyr->layer->type == RL2_MAP_LAYER_TOPOLOGY)
			  ret =
			      rl2_map_image_paint_from_vector_ex (sqlite, data,
								  (rl2CanvasPtr)
								  aux_lyr->
								  canvas,
								  aux_lyr->
								  prefix,
								  aux_lyr->
								  layer->name,
								  blob, blob_sz,


								  0,
								  aux_lyr->style_name,
								  (unsigned char
								   *)
								  aux_lyr->xml_style,
								  aux_lyr->
								  layer->
								  topology_style->
								  show_nodes,
								  aux_lyr->
								  layer->
								  topology_style->
								  show_edges,
								  aux_lyr->
								  layer->
								  topology_style->
								  show_faces,
								  aux_lyr->
								  layer->
								  topology_style->
								  show_edge_seeds,
								  aux_lyr->
								  layer->
								  topology_style->

								  show_face_seeds);
		      else if (aux_lyr->layer->type == RL2_MAP_LAYER_NETWORK)
			  ret =
			      rl2_map_image_paint_from_vector_ex (sqlite, data,
								  (rl2CanvasPtr)
								  aux_lyr->
								  canvas,
								  aux_lyr->
								  prefix,
								  aux_lyr->
								  layer->name,
								  blob, blob_sz,


								  0,
								  aux_lyr->style_name,
								  (unsigned char
								   *)
								  aux_lyr->xml_style,
								  aux_lyr->
								  layer->
								  network_style->
								  show_nodes,
								  aux_lyr->
								  layer->
								  network_style->
								  show_links, 0,
								  aux_lyr->
								  layer->
								  network_style->

								  show_link_seeds,
								  0);

		      else
			  ret = rl2_map_image_paint_from_vector (sqlite, data,
								 (rl2CanvasPtr)
								 aux_lyr->
								 canvas,
								 aux_lyr->
								 prefix,
								 aux_lyr->
								 layer->name,
								 blob, blob_sz,


								 0,
								 aux_lyr->style_name,
								 (unsigned char

								  *)
								 aux_lyr->xml_style);

		      if (ret == RL2_OK)
			  ret = rl2_graph_merge (aux->ctx, aux_lyr->ctx);






		  }
	    }
      }
    sqlite3_finalize (stmt);
}

static void
do_paint_layer_labels (sqlite3 * sqlite, const void *data,
		       rl2PrivMapLayerPtr aux_lyr, rl2PrivMapConfigAuxPtr aux)
{
/* rendering a MapConfiguration Layer Labels */
    sqlite3_stmt *stmt = NULL;
    const char *sql;
    int ret;

    if (aux_lyr == NULL)
	return;
    if (aux_lyr->layer == NULL)
	return;

/* building the Map's Bounding Box */
    sql = "SELECT BuildMbr(?, ?, ?, ?, ?)";
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	return;
    sqlite3_reset (stmt);
    sqlite3_clear_bindings (stmt);
    sqlite3_bind_double (stmt, 1, aux->min_x);
    sqlite3_bind_double (stmt, 2, aux->min_y);
    sqlite3_bind_double (stmt, 3, aux->max_x);
    sqlite3_bind_double (stmt, 4, aux->max_y);
    sqlite3_bind_int (stmt, 5, aux->srid);
    while (1)
      {
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;
	  if (ret == SQLITE_ROW)
	    {
		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
		  {
		      unsigned char *blob =
			  (unsigned char *) sqlite3_column_blob (stmt, 0);
		      int blob_sz = sqlite3_column_bytes (stmt, 0);
		      ret = rl2_map_image_paint_labels (sqlite, data,
							aux->canvas_labels,
							aux_lyr->prefix,
							aux_lyr->layer->name,
							blob, blob_sz, 0,
							aux_lyr->style_name,
							(unsigned char *)
							aux_lyr->xml_style);
		  }
	    }
      }
    sqlite3_finalize (stmt);
}

static void
................................................................................
							   aux_lyr->canvas,
							   aux_lyr->prefix,
							   aux_lyr->layer->name,
							   blob, blob_sz,
							   aux_lyr->style_name,
							   (unsigned char *)
							   aux_lyr->xml_style,

							   aux_lyr->syntetic_band);
		      if (ret == RL2_OK)
			  ret = rl2_graph_merge (aux->ctx, aux_lyr->ctx);
		  }
	    }
      }
    sqlite3_finalize (stmt);
}
................................................................................
	  if (aux->ctx != NULL && ctx_in != NULL)
	      rl2_graph_merge (aux->ctx, ctx_in);
	  if (ctx_in)
	      rl2_graph_destroy_context (ctx_in);
	  free (rgba);
      }
}

static void
check_map_labels (sqlite3 * sqlite, rl2PrivMapLayerPtr lyr)
{
/* testing for Layers with Map Labels */
    rl2MapLayerPtr layer = lyr->layer;
    rl2MapVectorLayerStylePtr style = layer->vector_style;
    lyr->has_labels = 0;
    if (style != NULL)
      {
	  /* quick style */
	  if (style->text_sym != NULL)
	      lyr->has_labels = 1;
      }
    else if (layer->vector_style_internal_name != NULL)
      {
	  /* internal style name */
	  rl2FeatureTypeStylePtr lyr_stl =
	      rl2_create_feature_type_style_from_dbms (sqlite, layer->prefix,
						       layer->name,
						       layer->
						       vector_style_internal_name);
	  if (lyr_stl != NULL)
	    {
		lyr->has_labels = rl2_style_has_labels (lyr_stl);
		rl2_destroy_feature_type_style (lyr_stl);
	    }
      }
}

RL2_PRIVATE int
rl2_paint_map_config_aux (sqlite3 * sqlite, const void *data,
			  rl2PrivMapConfigAuxPtr aux)
{
/* rendering a full MapConfiguration */
    rl2PrivMapLayerPtr aux_lyr;
................................................................................
    int half_transparent;
    unsigned char *image = NULL;
    int image_size;

    if (aux == NULL)
	return RL2_ERROR;

    aux->has_labels = 0;
    aux->update_labels = 0;
    aux_lyr = aux->first_lyr;
    while (aux_lyr != NULL)
      {
	  /* testing for Map Labels */
	  switch (aux_lyr->layer->type)
	    {
	    case RL2_MAP_LAYER_VECTOR:
	    case RL2_MAP_LAYER_VECTOR_VIEW:
	    case RL2_MAP_LAYER_VECTOR_VIRTUAL:
	    case RL2_MAP_LAYER_TOPOLOGY:
	    case RL2_MAP_LAYER_NETWORK:
		check_map_labels (sqlite, aux_lyr);
		if (aux_lyr->has_labels)
		    aux->has_labels = 1;
		break;
	    default:
		break;
	    };
	  aux_lyr = aux_lyr->next;
      }

	  aux_lyr = aux->first_lyr;
	  while (aux_lyr != NULL)
	    {
		/* painting Layers */
		if (aux_lyr->valid)
		  {
		      switch (aux_lyr->layer->type)
			{
			case RL2_MAP_LAYER_WMS:
			    do_paint_layer_wms (data, aux_lyr, aux);
			    break;
			case RL2_MAP_LAYER_RASTER:
			    do_paint_layer_raster (sqlite, data, aux_lyr, aux);
			    break;
			case RL2_MAP_LAYER_VECTOR:
			case RL2_MAP_LAYER_VECTOR_VIEW:
			case RL2_MAP_LAYER_VECTOR_VIRTUAL:
			case RL2_MAP_LAYER_TOPOLOGY:
			case RL2_MAP_LAYER_NETWORK:
			    do_paint_layer_vector (sqlite, data, aux_lyr, aux);
			    if (aux_lyr->has_labels)
				aux->update_labels = 1;
			    break;
			default:
			    break;
			};
		  }
		aux_lyr = aux_lyr->next;
	    }

    if (aux->has_labels && aux->update_labels)
      {
	  /* creating a Canvas for Map Labels */
	  aux->ctx_labels =
	      rl2_graph_create_context (data, aux->width, aux->height);
	  if (aux->ctx_labels != NULL)
	    {
		rl2_prime_background (aux->ctx_labels, 0, 0, 0, 0);	/* transparent background */
		aux->canvas_labels = rl2_create_raster_canvas (aux->ctx_labels);
	    }
	  if (aux->canvas_labels != NULL)
	    {
		aux_lyr = aux->first_lyr;
		while (aux_lyr != NULL)
		  {
		      /* painting Layers with Map Labels */
		      if (aux_lyr->valid && aux_lyr->has_labels)
			{
			    switch (aux_lyr->layer->type)
			      {
			      case RL2_MAP_LAYER_VECTOR:
			      case RL2_MAP_LAYER_VECTOR_VIEW:
			      case RL2_MAP_LAYER_VECTOR_VIRTUAL:
			      case RL2_MAP_LAYER_TOPOLOGY:
			      case RL2_MAP_LAYER_NETWORK:
				  do_paint_layer_labels (sqlite, data, aux_lyr,
							 aux);
				  break;
			      default:
				  break;
			      };
			}
		      aux_lyr = aux_lyr->next;
		  }
		rl2_graph_merge (aux->ctx, aux->ctx_labels);
	    }
      }

/* preparing the full rendered Map Image */
    rgb = rl2_graph_get_context_rgb_array (aux->ctx);
    alpha = rl2_graph_get_context_alpha_array (aux->ctx, &half_transparent);
    if (rgb == NULL || alpha == NULL)
	goto error;

Changes to src/rl2paint.c.

3847
3848
3849
3850
3851
3852
3853


3854
3855
3856
3857
3858
3859
3860
....
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
....
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
....
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
....
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
....
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
....
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
....
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
....
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
....
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
....
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
....
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
/* all children threads have now finished: resuming the main thread */
    for (i = 0; i < count; i++)
      {
	  params = params_array + i;
	  params->at_data = NULL;
	  params->in = NULL;
	  params->out = NULL;


	  params->opaque_thread_id = NULL;
      }
}

static void
do_mono_thread_transform (rl2TransformParamsPtr params)
{
................................................................................
    *buffer = mem->buffer;
    mem->buffer = NULL;
    *size = mem->write_offset;
    return RL2_OK;
}

RL2_DECLARE rl2CanvasPtr
rl2_create_vector_canvas (rl2GraphicsContextPtr ref_ctx,
			  rl2GraphicsContextPtr ref_ctx_labels)
{
/* allocating and initializing a Canvas object (generic Vector) */
    rl2PrivCanvasPtr canvas = NULL;
    if (ref_ctx == NULL)
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_VECTOR_CANVAS;
    canvas->ref_ctx = ref_ctx;
    canvas->ref_ctx_labels = ref_ctx_labels;
    canvas->ref_ctx_nodes = NULL;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;
    canvas->ctx_labels_ready = RL2_FALSE;
    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
    return (rl2CanvasPtr) canvas;
}

RL2_DECLARE rl2CanvasPtr
rl2_create_topology_canvas (rl2GraphicsContextPtr ref_ctx,
			    rl2GraphicsContextPtr ref_ctx_labels,
			    rl2GraphicsContextPtr ref_ctx_nodes,
			    rl2GraphicsContextPtr ref_ctx_edges,
			    rl2GraphicsContextPtr ref_ctx_faces,
			    rl2GraphicsContextPtr ref_ctx_edge_seeds,
			    rl2GraphicsContextPtr ref_ctx_face_seeds)
{
/* allocating and initializing a Canvas object (Topology) */
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_TOPOLOGY_CANVAS;
    canvas->ref_ctx = ref_ctx;
    canvas->ref_ctx_labels = ref_ctx_labels;
    canvas->ref_ctx_nodes = ref_ctx_nodes;
    canvas->ref_ctx_edges = ref_ctx_edges;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = ref_ctx_faces;
    canvas->ref_ctx_edge_seeds = ref_ctx_edge_seeds;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = ref_ctx_face_seeds;
    canvas->ctx_ready = RL2_FALSE;
    canvas->ctx_labels_ready = RL2_FALSE;
    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
    return (rl2CanvasPtr) canvas;
}

RL2_DECLARE rl2CanvasPtr
rl2_create_network_canvas (rl2GraphicsContextPtr ref_ctx,
			   rl2GraphicsContextPtr ref_ctx_labels,
			   rl2GraphicsContextPtr ref_ctx_nodes,
			   rl2GraphicsContextPtr ref_ctx_links,
			   rl2GraphicsContextPtr ref_ctx_link_seeds)
{
/* allocating and initializing a Canvas object (Network) */
    rl2PrivCanvasPtr canvas = NULL;
    if (ref_ctx == NULL)
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_NETWORK_CANVAS;
    canvas->ref_ctx = ref_ctx;
    canvas->ref_ctx_labels = ref_ctx_labels;
    canvas->ref_ctx_nodes = ref_ctx_nodes;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = ref_ctx_links;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = ref_ctx_link_seeds;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;
    canvas->ctx_labels_ready = RL2_FALSE;
    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_RASTER_CANVAS;
    canvas->ref_ctx = ref_ctx;
    canvas->ref_ctx_labels = NULL;
    canvas->ref_ctx_nodes = NULL;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;
    canvas->ctx_labels_ready = RL2_FALSE;
    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_WMS_CANVAS;
    canvas->ref_ctx = ref_ctx;
    canvas->ref_ctx_labels = NULL;
    canvas->ref_ctx_nodes = NULL;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;
    canvas->ctx_labels_ready = RL2_FALSE;
    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
................................................................................
    switch (canvas->type)
      {
      case RL2_VECTOR_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ctx_ready;
	    case RL2_CANVAS_LABELS_CTX:
		return canvas->ctx_labels_ready;
	    };
	  break;
      case RL2_RASTER_CANVAS:
      case RL2_WMS_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
................................................................................
	    };
	  break;
      case RL2_TOPOLOGY_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ctx_ready;
	    case RL2_CANVAS_LABELS_CTX:
		return canvas->ctx_labels_ready;
	    case RL2_CANVAS_NODES_CTX:
		return canvas->ctx_nodes_ready;
	    case RL2_CANVAS_EDGES_CTX:
		return canvas->ctx_edges_ready;
	    case RL2_CANVAS_FACES_CTX:
		return canvas->ctx_faces_ready;
	    case RL2_CANVAS_EDGE_SEEDS_CTX:
................................................................................
	    };
	  break;
      case RL2_NETWORK_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ctx_ready;
	    case RL2_CANVAS_LABELS_CTX:
		return canvas->ctx_labels_ready;
	    case RL2_CANVAS_NODES_CTX:
		return canvas->ctx_nodes_ready;
	    case RL2_CANVAS_LINKS_CTX:
		return canvas->ctx_links_ready;
	    case RL2_CANVAS_LINK_SEEDS_CTX:
		return canvas->ctx_link_seeds_ready;
	    };
................................................................................
      };
    return RL2_FALSE;
}

RL2_DECLARE rl2GraphicsContextPtr
rl2_get_canvas_ctx (rl2CanvasPtr ptr, int which)
{
/* return a pointer to soma Graphics Context from a Canvas */
    rl2PrivCanvasPtr canvas = (rl2PrivCanvasPtr) ptr;
    if (canvas == NULL)
	return NULL;
    switch (canvas->type)
      {
      case RL2_VECTOR_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ref_ctx;
	    case RL2_CANVAS_LABELS_CTX:
		return canvas->ref_ctx_labels;
	    };
	  break;
      case RL2_RASTER_CANVAS:
      case RL2_WMS_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
................................................................................
	    };
	  break;
      case RL2_TOPOLOGY_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ref_ctx;
	    case RL2_CANVAS_LABELS_CTX:
		return canvas->ref_ctx_labels;
	    case RL2_CANVAS_NODES_CTX:
		return canvas->ref_ctx_nodes;
	    case RL2_CANVAS_EDGES_CTX:
		return canvas->ref_ctx_edges;
	    case RL2_CANVAS_FACES_CTX:
		return canvas->ref_ctx_faces;
	    case RL2_CANVAS_EDGE_SEEDS_CTX:
................................................................................
	    };
	  break;
      case RL2_NETWORK_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ref_ctx;
	    case RL2_CANVAS_LABELS_CTX:
		return canvas->ref_ctx_labels;
	    case RL2_CANVAS_NODES_CTX:
		return canvas->ref_ctx_nodes;
	    case RL2_CANVAS_LINKS_CTX:
		return canvas->ref_ctx_links;
	    case RL2_CANVAS_LINK_SEEDS_CTX:
		return canvas->ref_ctx_link_seeds;
	    };







>
>







 







|
<











<








<












<







 







<








<












<







 







<








<







 







<








<







 







<








<







 







<
<







 







<
<







 







<
<







 







|










<
<







 







<
<







 







<
<







3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
....
5290
5291
5292
5293
5294
5295
5296
5297

5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308

5309
5310
5311
5312
5313
5314
5315
5316

5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328

5329
5330
5331
5332
5333
5334
5335
....
5341
5342
5343
5344
5345
5346
5347

5348
5349
5350
5351
5352
5353
5354
5355

5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367

5368
5369
5370
5371
5372
5373
5374
....
5377
5378
5379
5380
5381
5382
5383

5384
5385
5386
5387
5388
5389
5390
5391

5392
5393
5394
5395
5396
5397
5398
....
5408
5409
5410
5411
5412
5413
5414

5415
5416
5417
5418
5419
5420
5421
5422

5423
5424
5425
5426
5427
5428
5429
....
5439
5440
5441
5442
5443
5444
5445

5446
5447
5448
5449
5450
5451
5452
5453

5454
5455
5456
5457
5458
5459
5460
....
5491
5492
5493
5494
5495
5496
5497


5498
5499
5500
5501
5502
5503
5504
....
5506
5507
5508
5509
5510
5511
5512


5513
5514
5515
5516
5517
5518
5519
....
5523
5524
5525
5526
5527
5528
5529


5530
5531
5532
5533
5534
5535
5536
....
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555


5556
5557
5558
5559
5560
5561
5562
....
5564
5565
5566
5567
5568
5569
5570


5571
5572
5573
5574
5575
5576
5577
....
5581
5582
5583
5584
5585
5586
5587


5588
5589
5590
5591
5592
5593
5594
/* all children threads have now finished: resuming the main thread */
    for (i = 0; i < count; i++)
      {
	  params = params_array + i;
	  params->at_data = NULL;
	  params->in = NULL;
	  params->out = NULL;
	  if (params->opaque_thread_id != NULL)
	      free (params->opaque_thread_id);
	  params->opaque_thread_id = NULL;
      }
}

static void
do_mono_thread_transform (rl2TransformParamsPtr params)
{
................................................................................
    *buffer = mem->buffer;
    mem->buffer = NULL;
    *size = mem->write_offset;
    return RL2_OK;
}

RL2_DECLARE rl2CanvasPtr
rl2_create_vector_canvas (rl2GraphicsContextPtr ref_ctx)

{
/* allocating and initializing a Canvas object (generic Vector) */
    rl2PrivCanvasPtr canvas = NULL;
    if (ref_ctx == NULL)
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_VECTOR_CANVAS;
    canvas->ref_ctx = ref_ctx;

    canvas->ref_ctx_nodes = NULL;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;

    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
    return (rl2CanvasPtr) canvas;
}

RL2_DECLARE rl2CanvasPtr
rl2_create_topology_canvas (rl2GraphicsContextPtr ref_ctx,

			    rl2GraphicsContextPtr ref_ctx_nodes,
			    rl2GraphicsContextPtr ref_ctx_edges,
			    rl2GraphicsContextPtr ref_ctx_faces,
			    rl2GraphicsContextPtr ref_ctx_edge_seeds,
			    rl2GraphicsContextPtr ref_ctx_face_seeds)
{
/* allocating and initializing a Canvas object (Topology) */
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_TOPOLOGY_CANVAS;
    canvas->ref_ctx = ref_ctx;

    canvas->ref_ctx_nodes = ref_ctx_nodes;
    canvas->ref_ctx_edges = ref_ctx_edges;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = ref_ctx_faces;
    canvas->ref_ctx_edge_seeds = ref_ctx_edge_seeds;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = ref_ctx_face_seeds;
    canvas->ctx_ready = RL2_FALSE;

    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
    return (rl2CanvasPtr) canvas;
}

RL2_DECLARE rl2CanvasPtr
rl2_create_network_canvas (rl2GraphicsContextPtr ref_ctx,

			   rl2GraphicsContextPtr ref_ctx_nodes,
			   rl2GraphicsContextPtr ref_ctx_links,
			   rl2GraphicsContextPtr ref_ctx_link_seeds)
{
/* allocating and initializing a Canvas object (Network) */
    rl2PrivCanvasPtr canvas = NULL;
    if (ref_ctx == NULL)
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_NETWORK_CANVAS;
    canvas->ref_ctx = ref_ctx;

    canvas->ref_ctx_nodes = ref_ctx_nodes;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = ref_ctx_links;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = ref_ctx_link_seeds;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;

    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_RASTER_CANVAS;
    canvas->ref_ctx = ref_ctx;

    canvas->ref_ctx_nodes = NULL;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;

    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
................................................................................
	return NULL;

    canvas = malloc (sizeof (rl2PrivCanvas));
    if (canvas == NULL)
	return NULL;
    canvas->type = RL2_WMS_CANVAS;
    canvas->ref_ctx = ref_ctx;

    canvas->ref_ctx_nodes = NULL;
    canvas->ref_ctx_edges = NULL;
    canvas->ref_ctx_links = NULL;
    canvas->ref_ctx_faces = NULL;
    canvas->ref_ctx_edge_seeds = NULL;
    canvas->ref_ctx_link_seeds = NULL;
    canvas->ref_ctx_face_seeds = NULL;
    canvas->ctx_ready = RL2_FALSE;

    canvas->ctx_nodes_ready = RL2_FALSE;
    canvas->ctx_edges_ready = RL2_FALSE;
    canvas->ctx_links_ready = RL2_FALSE;
    canvas->ctx_faces_ready = RL2_FALSE;
    canvas->ctx_edge_seeds_ready = RL2_FALSE;
    canvas->ctx_link_seeds_ready = RL2_FALSE;
    canvas->ctx_face_seeds_ready = RL2_FALSE;
................................................................................
    switch (canvas->type)
      {
      case RL2_VECTOR_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ctx_ready;


	    };
	  break;
      case RL2_RASTER_CANVAS:
      case RL2_WMS_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
................................................................................
	    };
	  break;
      case RL2_TOPOLOGY_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ctx_ready;


	    case RL2_CANVAS_NODES_CTX:
		return canvas->ctx_nodes_ready;
	    case RL2_CANVAS_EDGES_CTX:
		return canvas->ctx_edges_ready;
	    case RL2_CANVAS_FACES_CTX:
		return canvas->ctx_faces_ready;
	    case RL2_CANVAS_EDGE_SEEDS_CTX:
................................................................................
	    };
	  break;
      case RL2_NETWORK_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ctx_ready;


	    case RL2_CANVAS_NODES_CTX:
		return canvas->ctx_nodes_ready;
	    case RL2_CANVAS_LINKS_CTX:
		return canvas->ctx_links_ready;
	    case RL2_CANVAS_LINK_SEEDS_CTX:
		return canvas->ctx_link_seeds_ready;
	    };
................................................................................
      };
    return RL2_FALSE;
}

RL2_DECLARE rl2GraphicsContextPtr
rl2_get_canvas_ctx (rl2CanvasPtr ptr, int which)
{
/* return a pointer to some Graphics Context from a Canvas */
    rl2PrivCanvasPtr canvas = (rl2PrivCanvasPtr) ptr;
    if (canvas == NULL)
	return NULL;
    switch (canvas->type)
      {
      case RL2_VECTOR_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ref_ctx;


	    };
	  break;
      case RL2_RASTER_CANVAS:
      case RL2_WMS_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
................................................................................
	    };
	  break;
      case RL2_TOPOLOGY_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ref_ctx;


	    case RL2_CANVAS_NODES_CTX:
		return canvas->ref_ctx_nodes;
	    case RL2_CANVAS_EDGES_CTX:
		return canvas->ref_ctx_edges;
	    case RL2_CANVAS_FACES_CTX:
		return canvas->ref_ctx_faces;
	    case RL2_CANVAS_EDGE_SEEDS_CTX:
................................................................................
	    };
	  break;
      case RL2_NETWORK_CANVAS:
	  switch (which)
	    {
	    case RL2_CANVAS_BASE_CTX:
		return canvas->ref_ctx;


	    case RL2_CANVAS_NODES_CTX:
		return canvas->ref_ctx_nodes;
	    case RL2_CANVAS_LINKS_CTX:
		return canvas->ref_ctx_links;
	    case RL2_CANVAS_LINK_SEEDS_CTX:
		return canvas->ref_ctx_link_seeds;
	    };

Changes to src/rl2rastersym.c.

8536
8537
8538
8539
8540
8541
8542

8543
8544
8545
8546
8547
8548
8549
      }
#endif

/* all children threads have now finished: resuming the main thread */
    for (i = 0; i < max_threads; i++)
      {
	  /* cleaning up a request slot */

	  if (shadower->opaque_thread_id != NULL)
	      free (shadower->opaque_thread_id);
	  shadower->opaque_thread_id = NULL;
      }
}

RL2_PRIVATE int







>







8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
      }
#endif

/* all children threads have now finished: resuming the main thread */
    for (i = 0; i < max_threads; i++)
      {
	  /* cleaning up a request slot */
	  shadower = aux + i;
	  if (shadower->opaque_thread_id != NULL)
	      free (shadower->opaque_thread_id);
	  shadower->opaque_thread_id = NULL;
      }
}

RL2_PRIVATE int

Changes to src/rl2sql.c.

597
598
599
600
601
602
603
604

605
606
607
608
609
610
611
...
613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
...
695
696
697
698
699
700
701
702

703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729

730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767

768
769
770
771
772
773
774
...
776
777
778
779
780
781
782
783

784
785
786
787
788
789
790
...
809
810
811
812
813
814
815
816

817
818
819
820
821
822
823
...
825
826
827
828
829
830
831
832

833
834
835
836
837
838
839
...
858
859
860
861
862
863
864
865

866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904

905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
...
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
....
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034

1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057

1058
1059
1060
1061

1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095

1096
1097
1098
1099
1100
1101
1102
....
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
....
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
....
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
....
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
....
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
....
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
....
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
....
3676
3677
3678
3679
3680
3681
3682

3683
3684
3685
3686
3687
3688
3689
....
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
....
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
....
8613
8614
8615
8616
8617
8618
8619
8620















































8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633

8634
8635
8636
8637
8638
8639
8640
....
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675

8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
....
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705

8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
....
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
....
8840
8841
8842
8843
8844
8845
8846







8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859

8860
8861
8862

8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873

8874
8875
8876
8877
8878
8879
8880
....
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920

8921

8922
8923

8924




































8925
8926
8927


8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
....
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
....
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
.....
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
.....
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
.....
12811
12812
12813
12814
12815
12816
12817










12818
12819
12820
12821
12822
12823

12824
12825
12826
12827
12828

12829
12830
12831
12832
12833



12834
12835
12836
12837
12838















12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850



12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
.....
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
	priv_data->max_threads = max_threads;
    else
	max_threads = 1;
    sqlite3_result_int (context, max_threads);
}

static void
fnct_GetMaxWmsRetries (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_GetMaxWmsRetries()
/
/ return the currently set Max number of WMS Retries
*/
    int max_wms_retries = 5;
................................................................................
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	max_wms_retries = priv_data->max_wms_retries;
    sqlite3_result_int (context, max_wms_retries);
}

static void
fnct_SetMaxWmsRetries (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_SetMaxWmsRetries(INTEGER max)
/
/ return the currently set Max number of WMS Retries (after this call)
/ -1 on invalid arguments
*/
................................................................................
	priv_data->wms_pause = wms_pause;
    else
	wms_pause = 1;
    sqlite3_result_int (context, wms_pause);
}

static void
fnct_GetPdfMarginUOM (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_GetPdfMarginUOM()
/
/ return the current Unity Of Measure for PDF empty margins
*/
    const char *uom = "in";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	{
		switch(priv_data->pdf_margin_uom)
		{
			case RL2_PDF_MARGIN_MILLIMS:
				uom = "mm";
				break;
			case RL2_PDF_MARGIN_INCHES:
			default:
				uom = "in";
				break;
		};
	}
    sqlite3_result_text (context, uom, strlen(uom), SQLITE_STATIC);
}

static void
fnct_SetPdfMarginUOM (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_SetPdfMarginUOM(text UOM)
/
/ return the current Unity Of Measure for PDF empty margins (after this call)
/ NULL on invalid arguments
*/
    const char *uom = "in";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	uom = (const char *)sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
    {
		if (strcasecmp(uom, "mm") == 0)
		{
			priv_data->pdf_margin_uom = RL2_PDF_MARGIN_MILLIMS;
			uom = "mm";
		}
		else
		{
			priv_data->pdf_margin_uom = RL2_PDF_MARGIN_INCHES;
			uom = "in";
		}
	}
    else
	uom = "in";
    sqlite3_result_text (context, uom, strlen(uom), SQLITE_STATIC);
}

static void
fnct_GetPdfMarginHorz (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_GetPdfMarginHorz()
/
/ return the currently set Horizontal PDF empty margin
*/
    double margin = 0.5;
................................................................................
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	margin = priv_data->pdf_margin_horz;
    sqlite3_result_double (context, margin);
}

static void
fnct_SetPdfMarginHorz (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_SetPdfMarginHorz(double MARGIN)
/
/ return the currently set Horizontal PDF empty margin (after this call)
/ -1 on invalid arguments
*/
................................................................................
	priv_data->pdf_margin_horz = margin;
    else
	margin = 0.5;
    sqlite3_result_double (context, margin);
}

static void
fnct_GetPdfMarginVert (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_GetPdfMarginVert()
/
/ return the currently set Horizontal PDF empty margin
*/
    double margin = 0.5;
................................................................................
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	margin = priv_data->pdf_margin_vert;
    sqlite3_result_double (context, margin);
}

static void
fnct_SetPdfMarginVert (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_SetPdfMarginVert(double MARGIN)
/
/ return the currently set Vertical PDF empty margin (after this call)
/ -1 on invalid arguments
*/
................................................................................
	priv_data->pdf_margin_vert = margin;
    else
	margin = 0.5;
    sqlite3_result_double (context, margin);
}

static void
fnct_GetPdfPaperFormat (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_GetPdfPaperFormat()
/
/ return the current PDF Paper Format
*/
    const char *format = "A4";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	{
		switch(priv_data->pdf_paper_format)
		{
			case RL2_PDF_PAPER_FORMAT_A0:
				format = "A0";
				break;
			case RL2_PDF_PAPER_FORMAT_A1:
				format = "A1";
				break;
			case RL2_PDF_PAPER_FORMAT_A2:
				format = "A2";
				break;
			case RL2_PDF_PAPER_FORMAT_A3:
				format = "A3";
				break;
			case RL2_PDF_PAPER_FORMAT_A5:
				format = "A5";
				break;
			case RL2_PDF_PAPER_FORMAT_A4:
			default:
				format = "A4";
				break;
		};
	}
    sqlite3_result_text (context, format, strlen(format), SQLITE_STATIC);
}

static void
fnct_SetPdfPaperFormat (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_SetPdfPaperFormat(text FORMAT)
/
/ return the current PDF Page Format (after this call)
/ NULL on invalid arguments
*/
    const char *format = "A4";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	format = (const char *)sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
    {
		if (strcasecmp(format, "A0") == 0)
		{
			priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A0;
			format = "A0";
		}
		else if (strcasecmp(format, "A1") == 0)
		{
			priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A1;
			format = "A1";
		}
		else if (strcasecmp(format, "A2") == 0)
		{
			priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A2;
			format = "A2";
		}
		else if (strcasecmp(format, "A3") == 0)
		{
			priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A3;
			format = "A3";
		}
		else if (strcasecmp(format, "A5") == 0)
		{
			priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A5;
			format = "A5";
		}
		else
		{
			priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A4;
			format = "A4";
		}
	}
    else
	format = "A4";
    sqlite3_result_text (context, format, strlen(format), SQLITE_STATIC);
}

static void
fnct_GetPdfDPI (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfDPI()
................................................................................
/
/ return the current PDF DPI setting
*/
    int dpi = 300;
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	{
		switch(priv_data->pdf_dpi)
		{
			case RL2_PDF_DPI_72:
				dpi = 72;
				break;
			case RL2_PDF_DPI_150:
				dpi = 150;
				break;
			case RL2_PDF_DPI_600:
				dpi = 600;
				break;
			case RL2_PDF_DPI_300:
			default:
				dpi = 300;
				break;
		};
	}
    sqlite3_result_int (context, dpi);
}

static void
fnct_SetPdfDPI (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
................................................................................
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
    {
		if (dpi == 72)
			priv_data->pdf_dpi = RL2_PDF_DPI_72;
		else if (dpi == 150)
			priv_data->pdf_dpi = RL2_PDF_DPI_150;
		else if (dpi == 600)
			priv_data->pdf_dpi = RL2_PDF_DPI_600;
		else
		{
			priv_data->pdf_dpi = RL2_PDF_DPI_300;
			dpi = 300;
		}
	}
    else
	dpi = 300;
    sqlite3_result_int (context, dpi);
}

static void
fnct_GetPdfOrientation (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_GetPdfOrientation()
/
/ return the current PDF Orientation setting
*/
    const char *orientation = "Portrait";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	{
		switch(priv_data->pdf_orientation)
		{
			case RL2_PDF_LANDSCAPE:
				orientation = "Landscape";
				break;
			case RL2_PDF_PORTRAIT:
			default:
				orientation = "Portrait";
				break;
		};
	}
    sqlite3_result_text (context, orientation, strlen(orientation), SQLITE_STATIC);

}

static void
fnct_SetPdfOrientation (sqlite3_context * context, int argc, sqlite3_value ** argv)

{
/* SQL function:
/ RL2_SetPdfOrientation(text ORIENTATION)
/
/ return the current PDF Orientation setting (after this call)
/ NULL on invalid arguments
*/
    const char *orientation = "Portrait";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	orientation = (const char *)sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
    {
		if (strcasecmp(orientation, "Landscape") == 0)
		{
			priv_data->pdf_orientation = RL2_PDF_LANDSCAPE;
			orientation = "Landscape";
		}
		else
		{
			priv_data->pdf_orientation = RL2_PDF_PORTRAIT;
			orientation = "Portrait";
		}
	}
    else
	orientation = "Portrait";
    sqlite3_result_text (context, orientation, strlen(orientation), SQLITE_STATIC);

}

static void
fnct_IsAntiLabelCollisionEnabled (sqlite3_context * context, int argc,
				  sqlite3_value ** argv)
{
/* SQL function:
................................................................................
    if (priv_data != NULL)
	priv_data->labeling.no_colliding_labels = 0;
    sqlite3_result_int (context, 0);
}

static void
fnct_IsLabelWrapTextEnabled (sqlite3_context * context, int argc,
				  sqlite3_value ** argv)
{
/* SQL function:
/ RL2_IsLabelWrapTextEnabled()
/
/ return if LabelWrapText is enabled or not
*/
    int anti = 0;
................................................................................
    if (anti != 0)
	anti = 1;
    sqlite3_result_int (context, anti);
}

static void
fnct_EnableLabelWrapText (sqlite3_context * context, int argc,
			       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_EnableLabelWrapText(void)
/
/ return if LabelWrapText has been enabled or not
*/
    int anti = 0;
................................................................................
	  anti = priv_data->labeling.label_wrap_text;
      }
    sqlite3_result_int (context, anti);
}

static void
fnct_DisableLabelWrapText (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ RL2_DisableLabelWrapText(void)
/
/ return zero
*/
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
................................................................................
    if (priv_data != NULL)
	priv_data->labeling.label_wrap_text = 0;
    sqlite3_result_int (context, 0);
}

static void
fnct_IsLabelAutorotateEnabled (sqlite3_context * context, int argc,
				  sqlite3_value ** argv)
{
/* SQL function:
/ RL2_IsLabelAutorotateEnabled()
/
/ return if LabelAutorotate is enabled or not
*/
    int anti = 0;
................................................................................
    if (anti != 0)
	anti = 1;
    sqlite3_result_int (context, anti);
}

static void
fnct_EnableLabelAutorotate (sqlite3_context * context, int argc,
			       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_EnableLabelAutorotate(void)
/
/ return if LabelAutorotate has been enabled or not
*/
    int anti = 0;
................................................................................
	  anti = priv_data->labeling.label_autorotate;
      }
    sqlite3_result_int (context, anti);
}

static void
fnct_DisableLabelAutorotate (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ RL2_DisableLabelAutorotate(void)
/
/ return zero
*/
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
................................................................................
}

static void
fnct_GetBandHistogramFromImage (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ GetBandHistogramFromImage(BLOBencoded statistics, TEXT mime_type, int band_index)
/
/ will return a PNG image representing the Histogram for the given Band
/ or NULL (INVALID ARGS)
/
*/
    const unsigned char *blob;
    int blob_sz;
................................................................................
/ Coverage of the MULTIBAND type and explicitly declaring
/ a default band mapping
/ returns 1 on success
/ 0 on failure, -1 on invalid arguments
*/
    const char *coverage_name;
    int on_off;

    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
................................................................................
    if (sqlite3_value_type (argv[1]) != SQLITE_INTEGER)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
    coverage_name = (const char *) sqlite3_value_text (argv[0]);
    on_off = sqlite3_value_int (argv[1]);
    if (rl2_enable_dbms_coverage_auto_ndvi (sqlite, coverage_name, on_off) ==
	RL2_OK)
	sqlite3_result_int (context, 1);
    else
	sqlite3_result_int (context, 0);
}

static void
fnct_IsRasterCoverageAutoNdviEnabled (sqlite3_context * context, int argc,
................................................................................
    int n;
    double x = 0.0;
    double y = 0.0;
    double tilew;
    double tileh;
    unsigned int tile_width;
    unsigned int tile_height;
    WmsRetryListPtr retry_list = NULL; 
    char *table;
    char *xtable;
    char *sql;
    sqlite3_stmt *stmt_data = NULL;
    sqlite3_stmt *stmt_tils = NULL;
    sqlite3_stmt *stmt_sect = NULL;
    sqlite3_stmt *stmt_policies = NULL;
................................................................................
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ascii_grid (1, context, argc, argv);
}
















































static void
common_write_ndvi_ascii_grid (int by_section, sqlite3_context * context,
			      int argc, sqlite3_value ** argv)
{
/* common export NDVI ASCII Grid implementation */
    int err = 0;
    const char *db_prefix = NULL;
    const char *cvg_name;
    const char *path;
    sqlite3_int64 section_id = 0;
    int width;
    int height;
    int red_band;

    int nir_band;
    const unsigned char *blob;
    int blob_sz;
    double resolution;
    rl2CoveragePtr coverage = NULL;
    sqlite3 *sqlite;
    const void *data;
................................................................................
	      err = 1;
	  if (sqlite3_value_type (argv[3]) != SQLITE_TEXT)
	      err = 1;
	  if (sqlite3_value_type (argv[4]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[5]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[6]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[7]) != SQLITE_INTEGER)

	      err = 1;
	  if (sqlite3_value_type (argv[8]) != SQLITE_BLOB)
	      err = 1;
	  if (sqlite3_value_type (argv[9]) != SQLITE_INTEGER
	      && sqlite3_value_type (argv[9]) != SQLITE_FLOAT)
	      err = 1;
	  if (argc > 10 && sqlite3_value_type (argv[10]) != SQLITE_INTEGER)
	      err = 1;
	  if (argc > 11 && sqlite3_value_type (argv[11]) != SQLITE_INTEGER)
	      err = 1;
      }
    else
      {
	  /* whole Coverage */
	  if (sqlite3_value_type (argv[0]) == SQLITE_TEXT
	      || sqlite3_value_type (argv[0]) == SQLITE_NULL)
................................................................................
	      err = 1;
	  if (sqlite3_value_type (argv[2]) != SQLITE_TEXT)
	      err = 1;
	  if (sqlite3_value_type (argv[3]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[4]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[5]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[6]) != SQLITE_INTEGER)

	      err = 1;
	  if (sqlite3_value_type (argv[7]) != SQLITE_BLOB)
	      err = 1;
	  if (sqlite3_value_type (argv[8]) != SQLITE_INTEGER
	      && sqlite3_value_type (argv[8]) != SQLITE_FLOAT)
	      err = 1;
	  if (argc > 9 && sqlite3_value_type (argv[9]) != SQLITE_INTEGER)
	      err = 1;
	  if (argc > 10 && sqlite3_value_type (argv[10]) != SQLITE_INTEGER)
	      err = 1;
      }
    if (err)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
................................................................................
	  if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	      db_prefix = (const char *) sqlite3_value_text (argv[0]);
	  cvg_name = (const char *) sqlite3_value_text (argv[1]);
	  section_id = sqlite3_value_int64 (argv[2]);
	  path = (const char *) sqlite3_value_text (argv[3]);
	  width = sqlite3_value_int (argv[4]);
	  height = sqlite3_value_int (argv[5]);
	  red_band = sqlite3_value_int (argv[6]);
	  nir_band = sqlite3_value_int (argv[7]);
	  blob = sqlite3_value_blob (argv[8]);
	  blob_sz = sqlite3_value_bytes (argv[8]);
	  if (sqlite3_value_type (argv[9]) == SQLITE_INTEGER)
	    {
		int ival = sqlite3_value_int (argv[9]);
		resolution = ival;
	    }
	  else
	      resolution = sqlite3_value_double (argv[9]);
	  if (argc > 10)
	      is_centered = sqlite3_value_int (argv[10]);
	  if (argc > 11)
	      decimal_digits = sqlite3_value_int (argv[11]);
      }
    else
      {
	  /* whole Coverage */
	  if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	      db_prefix = (const char *) sqlite3_value_text (argv[0]);
	  cvg_name = (const char *) sqlite3_value_text (argv[1]);
	  path = (const char *) sqlite3_value_text (argv[2]);
	  width = sqlite3_value_int (argv[3]);
	  height = sqlite3_value_int (argv[4]);
	  red_band = sqlite3_value_int (argv[5]);
	  nir_band = sqlite3_value_int (argv[6]);
	  blob = sqlite3_value_blob (argv[7]);
	  blob_sz = sqlite3_value_bytes (argv[7]);
	  if (sqlite3_value_type (argv[8]) == SQLITE_INTEGER)
	    {
		int ival = sqlite3_value_int (argv[8]);
		resolution = ival;
	    }
	  else
	      resolution = sqlite3_value_double (argv[8]);
	  if (argc > 9)
	      is_centered = sqlite3_value_int (argv[9]);
	  if (argc > 10)
	      decimal_digits = sqlite3_value_int (argv[10]);
      }

    if (decimal_digits < 1)
	decimal_digits = 0;
    if (decimal_digits > 18)
	decimal_digits = 18;

................................................................................
/* attempting to load the Coverage definitions from the DBMS */
    coverage = rl2_create_coverage_from_dbms (sqlite, db_prefix, cvg_name);
    if (coverage == NULL)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }








    if (by_section)
      {
	  /* single Section */
	  ret =
	      rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite,
							    max_threads, path,
							    coverage,
							    section_id,
							    resolution, minx,
							    miny, maxx, maxy,
							    width, height,
							    red_band,

							    nir_band,
							    is_centered,
							    decimal_digits);

      }
    else
      {
	  /* whole Coverage */
	  ret =
	      rl2_export_ndvi_ascii_grid_from_dbms (sqlite, max_threads, path,
						    coverage, resolution,
						    minx, miny, maxx, maxy,
						    width, height, red_band,
						    nir_band, is_centered,
						    decimal_digits);

      }
    if (ret != RL2_OK)
      {
	  errcode = 0;
	  goto error;
      }
    rl2_destroy_coverage (coverage);
................................................................................

static void
fnct_WriteNdviAsciiGrid (sqlite3_context * context, int argc,
			 sqlite3_value ** argv)
{
/* SQL function:
/ WriteNdviAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, int red_band, int nir_band, 
/                    BLOB geom, double resolution)
/ WriteNdviAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, int red_band, int nir_band, 
/                    BLOB geom, double resolution, int is_centered)
/ WriteNdviAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, int red_band, int nir_band, 
/                    BLOB geom, double resolution, int is_centered, 
/                    int decimal_digits)
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ndvi_ascii_grid (0, context, argc, argv);
}

static void
fnct_WriteSectionNdviAsciiGrid (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ WriteSectionNdviAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height, 
/                           int red_band, int nir_band, BLOB geom, 

/                           double resolution)

/ WriteSectionNdviAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height,

/                           int red_band, int nir_band, BLOB geom, 




































/                           double resolution, int is_centered)
/ WriteSectionNdviAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height,


/                           int red_band, int nir_band, BLOB geom, 
/                           double resolution, int is_centered,
/                           int decimal_digits)
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ndvi_ascii_grid (1, context, argc, argv);
}

static void
fnct_GetDrapingLastError (sqlite3_context * context, int argc,
			  sqlite3_value ** argv)
{
/* SQL function:
................................................................................
	sqlite3_result_null (context);
    else
	sqlite3_result_blob (context, image, image_size, free);
}

static void
fnct_GetImageFromMapConfiguration (sqlite3_context * context, int argc,
			    sqlite3_value ** argv)
{
/* SQL function:
/ GetImageFromMapConfiguration(text mapConf, BLOB geom, int width,
/                              int height)
/ GetImageFromMapConfiguration(text mapConf, BLOB geom, int width,
/                              int height, text format)
/ GetImageFromMapConfiguration(text mapConf, BLOB geom, int width, 
................................................................................
    if (argc > 6)
	reaspect = sqlite3_value_int (argv[6]);

    sqlite = sqlite3_context_db_handle (context);
    data = sqlite3_user_data (context);

    if (rl2_image_blob_from_map_config
	(sqlite, data, mapconf, blob, blob_sz, width, height, format, quality, reaspect, &image,
	 &image_size) != RL2_OK)
	sqlite3_result_null (context);
    else
	sqlite3_result_blob (context, image, image_size, free);
}

static void
fnct_GetTileImage (sqlite3_context * context, int argc, sqlite3_value ** argv)
................................................................................
static void
register_rl2_sql_functions (void *p_db, const void *p_data)
{
    sqlite3 *db = p_db;
    struct rl2_private_data *priv_data = (struct rl2_private_data *) p_data;
    const char *security_level;
    if (priv_data != NULL)
	  priv_data->labeling.sqlite = db;
    sqlite3_create_function (db, "rl2_version", 0,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
			     fnct_rl2_version, 0, 0);
    sqlite3_create_function (db, "rl2_cairo_version", 0,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
			     fnct_rl2_cairo_version, 0, 0);
    sqlite3_create_function (db, "rl2_curl_version", 0,
................................................................................
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetMapImageFromWMS, 0, 0);
    sqlite3_create_function (db, "GetMapImageFromWMS", 10,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetMapImageFromWMS, 0, 0);
    sqlite3_create_function (db, "RL2_GetMapImageFromWMS", 10,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetMapImageFromWMS, 0, 0);			     
    sqlite3_create_function (db, "GetImageFromMapConfiguration", 4,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetImageFromMapConfiguration, 0, 0);
    sqlite3_create_function (db, "RL2_GetImageFromMapConfiguration", 4,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetImageFromMapConfiguration, 0, 0);
    sqlite3_create_function (db, "GetImageFromMapConfiguration", 5,
................................................................................
				   fnct_WriteSectionAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 10,
				   SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid,
				   0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionAsciiGrid, 0, 0);










	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 9, SQLITE_UTF8,
				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 10, SQLITE_UTF8,

				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 11, SQLITE_UTF8,

				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 11,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 10,



				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);















	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 11,
				   SQLITE_UTF8, 0,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 11,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 12,
				   SQLITE_UTF8, 0,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 12,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);



	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 12,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
      }
}

#ifndef LOADABLE_EXTENSION

static void
rl2_splash_screen (int verbose)
................................................................................
    register_rl2_sql_functions (db, priv_data);
    *pzErrMsg = NULL;
    return 0;
}

#if !(defined _WIN32) || defined(__MINGW32__)
/* MSVC is unable to understand this declaration */
__attribute__ ((visibility ("default")))
#endif
     RL2_DECLARE int
	 sqlite3_modrasterlite_init (sqlite3 * db, char **pzErrMsg,
				     const sqlite3_api_routines * pApi)
{
/* SQLite invokes this routine once when it dynamically loads the extension. */
    return init_rl2_extension (db, pzErrMsg, pApi);
}

#endif







|
>







 







|
>







 







|
>










|
|
|
|
|
|
|
|
|
|
|
|
|



|
>











|







|
|
|
|
|
|
|
|
|
|
|
|


|



|
>







 







|
>







 







|
>







 







|
>







 







|
>










|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|



|
>











|







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


|







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







 







|
|
|
|
|
|
|
|
|
|
|
|
|






|
>










|
|
|
|
|
|
|
|
|
|
|
|
|
>



|
>











|







|
|
|
|
|
|
|
|
|
|
|
|


|
>







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







>







 







|
|







 







|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|

|







|
>







 







|

|
>

|

|
<
<
<
<
<







 







|

|
>

|

|
<
<
<
<
<







 







<
<
|
|
|

|



|
|
|
|
|










<
<
|
|
|

|



|
|
|
|
|







 







>
>
>
>
>
>
>













>


|
>









|
|
>







 







|
<

|
|

|
<
|





|









|
>
|
>


>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|

>
>
|
|






|







 







|







 







|
|







 







|







 







|







 







>
>
>
>
>
>
>
>
>
>





|
>
|
|

|
|
>
|
|

|

>
>
>





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|

|
|

|
|

|
>
>
>
|

|







 







|










597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
...
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
...
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
...
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
...
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
...
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
...
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
...
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
....
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
....
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
....
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
....
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
....
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
....
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
....
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
....
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
....
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
....
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
....
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
....
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
....
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743





8744
8745
8746
8747
8748
8749
8750
....
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769





8770
8771
8772
8773
8774
8775
8776
....
8782
8783
8784
8785
8786
8787
8788


8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811


8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
....
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
....
8950
8951
8952
8953
8954
8955
8956
8957

8958
8959
8960
8961
8962

8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
....
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
.....
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
.....
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
.....
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
.....
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
.....
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
	priv_data->max_threads = max_threads;
    else
	max_threads = 1;
    sqlite3_result_int (context, max_threads);
}

static void
fnct_GetMaxWmsRetries (sqlite3_context * context, int argc,
		       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetMaxWmsRetries()
/
/ return the currently set Max number of WMS Retries
*/
    int max_wms_retries = 5;
................................................................................
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	max_wms_retries = priv_data->max_wms_retries;
    sqlite3_result_int (context, max_wms_retries);
}

static void
fnct_SetMaxWmsRetries (sqlite3_context * context, int argc,
		       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_SetMaxWmsRetries(INTEGER max)
/
/ return the currently set Max number of WMS Retries (after this call)
/ -1 on invalid arguments
*/
................................................................................
	priv_data->wms_pause = wms_pause;
    else
	wms_pause = 1;
    sqlite3_result_int (context, wms_pause);
}

static void
fnct_GetPdfMarginUOM (sqlite3_context * context, int argc,
		      sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfMarginUOM()
/
/ return the current Unity Of Measure for PDF empty margins
*/
    const char *uom = "in";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
      {
	  switch (priv_data->pdf_margin_uom)
	    {
	    case RL2_PDF_MARGIN_MILLIMS:
		uom = "mm";
		break;
	    case RL2_PDF_MARGIN_INCHES:
	    default:
		uom = "in";
		break;
	    };
      }
    sqlite3_result_text (context, uom, strlen (uom), SQLITE_STATIC);
}

static void
fnct_SetPdfMarginUOM (sqlite3_context * context, int argc,
		      sqlite3_value ** argv)
{
/* SQL function:
/ RL2_SetPdfMarginUOM(text UOM)
/
/ return the current Unity Of Measure for PDF empty margins (after this call)
/ NULL on invalid arguments
*/
    const char *uom = "in";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	uom = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
      {
	  if (strcasecmp (uom, "mm") == 0)
	    {
		priv_data->pdf_margin_uom = RL2_PDF_MARGIN_MILLIMS;
		uom = "mm";
	    }
	  else
	    {
		priv_data->pdf_margin_uom = RL2_PDF_MARGIN_INCHES;
		uom = "in";
	    }
      }
    else
	uom = "in";
    sqlite3_result_text (context, uom, strlen (uom), SQLITE_STATIC);
}

static void
fnct_GetPdfMarginHorz (sqlite3_context * context, int argc,
		       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfMarginHorz()
/
/ return the currently set Horizontal PDF empty margin
*/
    double margin = 0.5;
................................................................................
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	margin = priv_data->pdf_margin_horz;
    sqlite3_result_double (context, margin);
}

static void
fnct_SetPdfMarginHorz (sqlite3_context * context, int argc,
		       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_SetPdfMarginHorz(double MARGIN)
/
/ return the currently set Horizontal PDF empty margin (after this call)
/ -1 on invalid arguments
*/
................................................................................
	priv_data->pdf_margin_horz = margin;
    else
	margin = 0.5;
    sqlite3_result_double (context, margin);
}

static void
fnct_GetPdfMarginVert (sqlite3_context * context, int argc,
		       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfMarginVert()
/
/ return the currently set Horizontal PDF empty margin
*/
    double margin = 0.5;
................................................................................
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
	margin = priv_data->pdf_margin_vert;
    sqlite3_result_double (context, margin);
}

static void
fnct_SetPdfMarginVert (sqlite3_context * context, int argc,
		       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_SetPdfMarginVert(double MARGIN)
/
/ return the currently set Vertical PDF empty margin (after this call)
/ -1 on invalid arguments
*/
................................................................................
	priv_data->pdf_margin_vert = margin;
    else
	margin = 0.5;
    sqlite3_result_double (context, margin);
}

static void
fnct_GetPdfPaperFormat (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfPaperFormat()
/
/ return the current PDF Paper Format
*/
    const char *format = "A4";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
      {
	  switch (priv_data->pdf_paper_format)
	    {
	    case RL2_PDF_PAPER_FORMAT_A0:
		format = "A0";
		break;
	    case RL2_PDF_PAPER_FORMAT_A1:
		format = "A1";
		break;
	    case RL2_PDF_PAPER_FORMAT_A2:
		format = "A2";
		break;
	    case RL2_PDF_PAPER_FORMAT_A3:
		format = "A3";
		break;
	    case RL2_PDF_PAPER_FORMAT_A5:
		format = "A5";
		break;
	    case RL2_PDF_PAPER_FORMAT_A4:
	    default:
		format = "A4";
		break;
	    };
      }
    sqlite3_result_text (context, format, strlen (format), SQLITE_STATIC);
}

static void
fnct_SetPdfPaperFormat (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ RL2_SetPdfPaperFormat(text FORMAT)
/
/ return the current PDF Page Format (after this call)
/ NULL on invalid arguments
*/
    const char *format = "A4";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	format = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
      {
	  if (strcasecmp (format, "A0") == 0)
	    {
		priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A0;
		format = "A0";
	    }
	  else if (strcasecmp (format, "A1") == 0)
	    {
		priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A1;
		format = "A1";
	    }
	  else if (strcasecmp (format, "A2") == 0)
	    {
		priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A2;
		format = "A2";
	    }
	  else if (strcasecmp (format, "A3") == 0)
	    {
		priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A3;
		format = "A3";
	    }
	  else if (strcasecmp (format, "A5") == 0)
	    {
		priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A5;
		format = "A5";
	    }
	  else
	    {
		priv_data->pdf_paper_format = RL2_PDF_PAPER_FORMAT_A4;
		format = "A4";
	    }
      }
    else
	format = "A4";
    sqlite3_result_text (context, format, strlen (format), SQLITE_STATIC);
}

static void
fnct_GetPdfDPI (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfDPI()
................................................................................
/
/ return the current PDF DPI setting
*/
    int dpi = 300;
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
      {
	  switch (priv_data->pdf_dpi)
	    {
	    case RL2_PDF_DPI_72:
		dpi = 72;
		break;
	    case RL2_PDF_DPI_150:
		dpi = 150;
		break;
	    case RL2_PDF_DPI_600:
		dpi = 600;
		break;
	    case RL2_PDF_DPI_300:
	    default:
		dpi = 300;
		break;
	    };
      }
    sqlite3_result_int (context, dpi);
}

static void
fnct_SetPdfDPI (sqlite3_context * context, int argc, sqlite3_value ** argv)
{
/* SQL function:
................................................................................
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
      {
	  if (dpi == 72)
	      priv_data->pdf_dpi = RL2_PDF_DPI_72;
	  else if (dpi == 150)
	      priv_data->pdf_dpi = RL2_PDF_DPI_150;
	  else if (dpi == 600)
	      priv_data->pdf_dpi = RL2_PDF_DPI_600;
	  else
	    {
		priv_data->pdf_dpi = RL2_PDF_DPI_300;
		dpi = 300;
	    }
      }
    else
	dpi = 300;
    sqlite3_result_int (context, dpi);
}

static void
fnct_GetPdfOrientation (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ RL2_GetPdfOrientation()
/
/ return the current PDF Orientation setting
*/
    const char *orientation = "Portrait";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (priv_data != NULL)
      {
	  switch (priv_data->pdf_orientation)
	    {
	    case RL2_PDF_LANDSCAPE:
		orientation = "Landscape";
		break;
	    case RL2_PDF_PORTRAIT:
	    default:
		orientation = "Portrait";
		break;
	    };
      }
    sqlite3_result_text (context, orientation, strlen (orientation),
			 SQLITE_STATIC);
}

static void
fnct_SetPdfOrientation (sqlite3_context * context, int argc,
			sqlite3_value ** argv)
{
/* SQL function:
/ RL2_SetPdfOrientation(text ORIENTATION)
/
/ return the current PDF Orientation setting (after this call)
/ NULL on invalid arguments
*/
    const char *orientation = "Portrait";
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	orientation = (const char *) sqlite3_value_text (argv[0]);
    else
      {
	  sqlite3_result_null (context);
	  return;
      }

    if (priv_data != NULL)
      {
	  if (strcasecmp (orientation, "Landscape") == 0)
	    {
		priv_data->pdf_orientation = RL2_PDF_LANDSCAPE;
		orientation = "Landscape";
	    }
	  else
	    {
		priv_data->pdf_orientation = RL2_PDF_PORTRAIT;
		orientation = "Portrait";
	    }
      }
    else
	orientation = "Portrait";
    sqlite3_result_text (context, orientation, strlen (orientation),
			 SQLITE_STATIC);
}

static void
fnct_IsAntiLabelCollisionEnabled (sqlite3_context * context, int argc,
				  sqlite3_value ** argv)
{
/* SQL function:
................................................................................
    if (priv_data != NULL)
	priv_data->labeling.no_colliding_labels = 0;
    sqlite3_result_int (context, 0);
}

static void
fnct_IsLabelWrapTextEnabled (sqlite3_context * context, int argc,
			     sqlite3_value ** argv)
{
/* SQL function:
/ RL2_IsLabelWrapTextEnabled()
/
/ return if LabelWrapText is enabled or not
*/
    int anti = 0;
................................................................................
    if (anti != 0)
	anti = 1;
    sqlite3_result_int (context, anti);
}

static void
fnct_EnableLabelWrapText (sqlite3_context * context, int argc,
			  sqlite3_value ** argv)
{
/* SQL function:
/ RL2_EnableLabelWrapText(void)
/
/ return if LabelWrapText has been enabled or not
*/
    int anti = 0;
................................................................................
	  anti = priv_data->labeling.label_wrap_text;
      }
    sqlite3_result_int (context, anti);
}

static void
fnct_DisableLabelWrapText (sqlite3_context * context, int argc,
			   sqlite3_value ** argv)
{
/* SQL function:
/ RL2_DisableLabelWrapText(void)
/
/ return zero
*/
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
................................................................................
    if (priv_data != NULL)
	priv_data->labeling.label_wrap_text = 0;
    sqlite3_result_int (context, 0);
}

static void
fnct_IsLabelAutorotateEnabled (sqlite3_context * context, int argc,
			       sqlite3_value ** argv)
{
/* SQL function:
/ RL2_IsLabelAutorotateEnabled()
/
/ return if LabelAutorotate is enabled or not
*/
    int anti = 0;
................................................................................
    if (anti != 0)
	anti = 1;
    sqlite3_result_int (context, anti);
}

static void
fnct_EnableLabelAutorotate (sqlite3_context * context, int argc,
			    sqlite3_value ** argv)
{
/* SQL function:
/ RL2_EnableLabelAutorotate(void)
/
/ return if LabelAutorotate has been enabled or not
*/
    int anti = 0;
................................................................................
	  anti = priv_data->labeling.label_autorotate;
      }
    sqlite3_result_int (context, anti);
}

static void
fnct_DisableLabelAutorotate (sqlite3_context * context, int argc,
			     sqlite3_value ** argv)
{
/* SQL function:
/ RL2_DisableLabelAutorotate(void)
/
/ return zero
*/
    struct rl2_private_data *priv_data = sqlite3_user_data (context);
................................................................................
}

static void
fnct_GetBandHistogramFromImage (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ GetBandHistogramFromImage(BLOBencoded image, TEXT mime_type, int band_index)
/
/ will return a PNG image representing the Histogram for the given Band
/ or NULL (INVALID ARGS)
/
*/
    const unsigned char *blob;
    int blob_sz;
................................................................................
/ Coverage of the MULTIBAND type and explicitly declaring
/ a default band mapping
/ returns 1 on success
/ 0 on failure, -1 on invalid arguments
*/
    const char *coverage_name;
    int on_off;
    int ret;
    sqlite3 *sqlite = sqlite3_context_db_handle (context);
    RL2_UNUSED ();		/* LCOV_EXCL_LINE */
    if (sqlite3_value_type (argv[0]) != SQLITE_TEXT)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
................................................................................
    if (sqlite3_value_type (argv[1]) != SQLITE_INTEGER)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
    coverage_name = (const char *) sqlite3_value_text (argv[0]);
    on_off = sqlite3_value_int (argv[1]);
    ret = rl2_enable_dbms_coverage_auto_ndvi (sqlite, coverage_name, on_off);
    if (ret == RL2_OK)
	sqlite3_result_int (context, 1);
    else
	sqlite3_result_int (context, 0);
}

static void
fnct_IsRasterCoverageAutoNdviEnabled (sqlite3_context * context, int argc,
................................................................................
    int n;
    double x = 0.0;
    double y = 0.0;
    double tilew;
    double tileh;
    unsigned int tile_width;
    unsigned int tile_height;
    WmsRetryListPtr retry_list = NULL;
    char *table;
    char *xtable;
    char *sql;
    sqlite3_stmt *stmt_data = NULL;
    sqlite3_stmt *stmt_tils = NULL;
    sqlite3_stmt *stmt_sect = NULL;
    sqlite3_stmt *stmt_policies = NULL;
................................................................................
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ascii_grid (1, context, argc, argv);
}

static int
do_retrieve_ndvi_band_selection (sqlite3 * sqlite, const char *db_prefix,
				 const char *cvg_name, int *red_band,
				 int *green_band, int *nir_band)
{
/* attempting to retrieve the NDVI/NDWI Default Band selection */
    int ret;
    char **results;
    int rows;
    int columns;
    int i;
    char *sql;
    char *xdb_prefix;
    int cnt = 0;

    if (db_prefix == NULL)
	db_prefix = "main";
    xdb_prefix = rl2_double_quoted_sql (db_prefix);
    sql =
	sqlite3_mprintf
	("SELECT red_band_index, green_band_index, nir_band_index FROM \"%s\".raster_coverages "
	 "WHERE coverage_name = Lower(%Q) AND red_band_index IS NOT NULL "
	 "AND green_band_index IS NOT NULL AND nir_band_index IS NOT NULL "
	 "AND enable_auto_ndvi = 1", xdb_prefix, cvg_name);
    free (xdb_prefix);
    ret = sqlite3_get_table (sqlite, sql, &results, &rows, &columns, NULL);
    sqlite3_free (sql);
    if (ret != SQLITE_OK)
	goto error;
    for (i = 1; i <= rows; i++)
      {
	  const char *red = results[(i * columns) + 0];
	  const char *green = results[(i * columns) + 1];
	  const char *nir = results[(i * columns) + 2];
	  *red_band = atoi (red);
	  *green_band = atoi (green);
	  *nir_band = atoi (nir);
	  cnt++;
      }
    sqlite3_free_table (results);
    if (cnt == 1)
	return 1;

  error:
    return 0;
}

static void
common_write_ndvi_ascii_grid (int by_section, sqlite3_context * context,
			      int argc, sqlite3_value ** argv, int ndwi_mode)
{
/* common export NDVI/NDWI ASCII Grid implementation */
    int err = 0;
    const char *db_prefix = NULL;
    const char *cvg_name;
    const char *path;
    sqlite3_int64 section_id = 0;
    int width;
    int height;
    int red_band = -1;
    int green_band = -1;
    int nir_band;
    const unsigned char *blob;
    int blob_sz;
    double resolution;
    rl2CoveragePtr coverage = NULL;
    sqlite3 *sqlite;
    const void *data;
................................................................................
	      err = 1;
	  if (sqlite3_value_type (argv[3]) != SQLITE_TEXT)
	      err = 1;
	  if (sqlite3_value_type (argv[4]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[5]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[6]) != SQLITE_BLOB)
	      err = 1;
	  if (sqlite3_value_type (argv[7]) != SQLITE_INTEGER
	      && sqlite3_value_type (argv[7]) != SQLITE_FLOAT)
	      err = 1;
	  if (argc > 8 && sqlite3_value_type (argv[8]) != SQLITE_INTEGER)
	      err = 1;
	  if (argc > 9 && sqlite3_value_type (argv[9]) != SQLITE_INTEGER)





	      err = 1;
      }
    else
      {
	  /* whole Coverage */
	  if (sqlite3_value_type (argv[0]) == SQLITE_TEXT
	      || sqlite3_value_type (argv[0]) == SQLITE_NULL)
................................................................................
	      err = 1;
	  if (sqlite3_value_type (argv[2]) != SQLITE_TEXT)
	      err = 1;
	  if (sqlite3_value_type (argv[3]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[4]) != SQLITE_INTEGER)
	      err = 1;
	  if (sqlite3_value_type (argv[5]) != SQLITE_BLOB)
	      err = 1;
	  if (sqlite3_value_type (argv[6]) != SQLITE_INTEGER
	      && sqlite3_value_type (argv[6]) != SQLITE_FLOAT)
	      err = 1;
	  if (argc > 7 && sqlite3_value_type (argv[7]) != SQLITE_INTEGER)
	      err = 1;
	  if (argc > 8 && sqlite3_value_type (argv[8]) != SQLITE_INTEGER)





	      err = 1;
      }
    if (err)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
................................................................................
	  if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	      db_prefix = (const char *) sqlite3_value_text (argv[0]);
	  cvg_name = (const char *) sqlite3_value_text (argv[1]);
	  section_id = sqlite3_value_int64 (argv[2]);
	  path = (const char *) sqlite3_value_text (argv[3]);
	  width = sqlite3_value_int (argv[4]);
	  height = sqlite3_value_int (argv[5]);


	  blob = sqlite3_value_blob (argv[6]);
	  blob_sz = sqlite3_value_bytes (argv[6]);
	  if (sqlite3_value_type (argv[7]) == SQLITE_INTEGER)
	    {
		int ival = sqlite3_value_int (argv[7]);
		resolution = ival;
	    }
	  else
	      resolution = sqlite3_value_double (argv[7]);
	  if (argc > 8)
	      is_centered = sqlite3_value_int (argv[8]);
	  if (argc > 9)
	      decimal_digits = sqlite3_value_int (argv[9]);
      }
    else
      {
	  /* whole Coverage */
	  if (sqlite3_value_type (argv[0]) == SQLITE_TEXT)
	      db_prefix = (const char *) sqlite3_value_text (argv[0]);
	  cvg_name = (const char *) sqlite3_value_text (argv[1]);
	  path = (const char *) sqlite3_value_text (argv[2]);
	  width = sqlite3_value_int (argv[3]);
	  height = sqlite3_value_int (argv[4]);


	  blob = sqlite3_value_blob (argv[5]);
	  blob_sz = sqlite3_value_bytes (argv[5]);
	  if (sqlite3_value_type (argv[6]) == SQLITE_INTEGER)
	    {
		int ival = sqlite3_value_int (argv[6]);
		resolution = ival;
	    }
	  else
	      resolution = sqlite3_value_double (argv[6]);
	  if (argc > 7)
	      is_centered = sqlite3_value_int (argv[7]);
	  if (argc > 8)
	      decimal_digits = sqlite3_value_int (argv[8]);
      }

    if (decimal_digits < 1)
	decimal_digits = 0;
    if (decimal_digits > 18)
	decimal_digits = 18;

................................................................................
/* attempting to load the Coverage definitions from the DBMS */
    coverage = rl2_create_coverage_from_dbms (sqlite, db_prefix, cvg_name);
    if (coverage == NULL)
      {
	  sqlite3_result_int (context, -1);
	  return;
      }
/* attempting to retrieve the Default Band NDVI selection */
    if (!do_retrieve_ndvi_band_selection
	(sqlite, db_prefix, cvg_name, &red_band, &green_band, &nir_band))
      {
	  sqlite3_result_int (context, -1);
	  return;
      }

    if (by_section)
      {
	  /* single Section */
	  ret =
	      rl2_export_section_ndvi_ascii_grid_from_dbms (sqlite,
							    max_threads, path,
							    coverage,
							    section_id,
							    resolution, minx,
							    miny, maxx, maxy,
							    width, height,
							    red_band,
							    green_band,
							    nir_band,
							    is_centered,
							    decimal_digits,
							    ndwi_mode);
      }
    else
      {
	  /* whole Coverage */
	  ret =
	      rl2_export_ndvi_ascii_grid_from_dbms (sqlite, max_threads, path,
						    coverage, resolution,
						    minx, miny, maxx, maxy,
						    width, height, red_band,
						    green_band, nir_band,
						    is_centered, decimal_digits,
						    ndwi_mode);
      }
    if (ret != RL2_OK)
      {
	  errcode = 0;
	  goto error;
      }
    rl2_destroy_coverage (coverage);
................................................................................

static void
fnct_WriteNdviAsciiGrid (sqlite3_context * context, int argc,
			 sqlite3_value ** argv)
{
/* SQL function:
/ WriteNdviAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, BLOB geom, double resolution)

/ WriteNdviAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, BLOB geom, double resolution,
/                    int is_centered)
/ WriteNdviAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, BLOB geom, double resolution, 

/                    int is_centered, int decimal_digits)
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ndvi_ascii_grid (0, context, argc, argv, 0);
}

static void
fnct_WriteSectionNdviAsciiGrid (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ WriteSectionNdviAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height, 
/                           BLOB geom, double resolution)
/ WriteSectionNdviAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height,
/                           BLOB geom, double resolution, int is_centered)
/ WriteSectionNdviAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height,
/                           BLOB geom, double resolution, int is_centered,
/                           int decimal_digits)
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ndvi_ascii_grid (1, context, argc, argv, 0);
}

static void
fnct_WriteNdwiAsciiGrid (sqlite3_context * context, int argc,
			 sqlite3_value ** argv)
{
/* SQL function:
/ WriteNdwiAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, BLOB geom, double resolution)
/ WriteNdwiAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, BLOB geom, double resolution,
/                    int is_centered)
/ WriteNdwiAsciiGrid(text db_prefix, text coverage, text ascii_path, 
/                    int width, int height, BLOB geom, double resolution,
/                    int is_centered, int decimal_digits)
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ndvi_ascii_grid (0, context, argc, argv, 1);
}

static void
fnct_WriteSectionNdwiAsciiGrid (sqlite3_context * context, int argc,
				sqlite3_value ** argv)
{
/* SQL function:
/ WriteSectionNdwiAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height, 
/                           BLOB geom, double resolution)
/ WriteSectionNdwiAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height,
/                           BLOB geom, double resolution, int is_centered)
/ WriteSectionNdwiAsciiGrid(text db_prefix, text coverage, int section_id,
/                           text ascii_path, int width, int height,
/                           BLOB geom, double resolution, int is_centered,
/                           int decimal_digits)
/
/ will return 1 (TRUE, success) or 0 (FALSE, failure)
/ or -1 (INVALID ARGS)
/
*/
    common_write_ndvi_ascii_grid (1, context, argc, argv, 1);
}

static void
fnct_GetDrapingLastError (sqlite3_context * context, int argc,
			  sqlite3_value ** argv)
{
/* SQL function:
................................................................................
	sqlite3_result_null (context);
    else
	sqlite3_result_blob (context, image, image_size, free);
}

static void
fnct_GetImageFromMapConfiguration (sqlite3_context * context, int argc,
				   sqlite3_value ** argv)
{
/* SQL function:
/ GetImageFromMapConfiguration(text mapConf, BLOB geom, int width,
/                              int height)
/ GetImageFromMapConfiguration(text mapConf, BLOB geom, int width,
/                              int height, text format)
/ GetImageFromMapConfiguration(text mapConf, BLOB geom, int width, 
................................................................................
    if (argc > 6)
	reaspect = sqlite3_value_int (argv[6]);

    sqlite = sqlite3_context_db_handle (context);
    data = sqlite3_user_data (context);

    if (rl2_image_blob_from_map_config
	(sqlite, data, mapconf, blob, blob_sz, width, height, format, quality,
	 reaspect, &image, &image_size) != RL2_OK)
	sqlite3_result_null (context);
    else
	sqlite3_result_blob (context, image, image_size, free);
}

static void
fnct_GetTileImage (sqlite3_context * context, int argc, sqlite3_value ** argv)
................................................................................
static void
register_rl2_sql_functions (void *p_db, const void *p_data)
{
    sqlite3 *db = p_db;
    struct rl2_private_data *priv_data = (struct rl2_private_data *) p_data;
    const char *security_level;
    if (priv_data != NULL)
	priv_data->labeling.sqlite = db;
    sqlite3_create_function (db, "rl2_version", 0,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
			     fnct_rl2_version, 0, 0);
    sqlite3_create_function (db, "rl2_cairo_version", 0,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
			     fnct_rl2_cairo_version, 0, 0);
    sqlite3_create_function (db, "rl2_curl_version", 0,
................................................................................
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetMapImageFromWMS, 0, 0);
    sqlite3_create_function (db, "GetMapImageFromWMS", 10,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetMapImageFromWMS, 0, 0);
    sqlite3_create_function (db, "RL2_GetMapImageFromWMS", 10,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetMapImageFromWMS, 0, 0);
    sqlite3_create_function (db, "GetImageFromMapConfiguration", 4,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetImageFromMapConfiguration, 0, 0);
    sqlite3_create_function (db, "RL2_GetImageFromMapConfiguration", 4,
			     SQLITE_UTF8 | SQLITE_DETERMINISTIC, priv_data,
			     fnct_GetImageFromMapConfiguration, 0, 0);
    sqlite3_create_function (db, "GetImageFromMapConfiguration", 5,
................................................................................
				   fnct_WriteSectionAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionAsciiGrid", 10,
				   SQLITE_UTF8, 0, fnct_WriteSectionAsciiGrid,
				   0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 7, SQLITE_UTF8,
				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 7,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 8, SQLITE_UTF8,
				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 8,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdviAsciiGrid", 9, SQLITE_UTF8,
				   priv_data, fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdviAsciiGrid", 9,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 8,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 8,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 9,
				   SQLITE_UTF8, 0,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 9,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdviAsciiGrid", 10,
				   SQLITE_UTF8, 0,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdviAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdviAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdwiAsciiGrid", 7, SQLITE_UTF8,
				   priv_data, fnct_WriteNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdwiAsciiGrid", 7,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdwiAsciiGrid", 8, SQLITE_UTF8,
				   priv_data, fnct_WriteNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdwiAsciiGrid", 8,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteNdwiAsciiGrid", 9, SQLITE_UTF8,
				   priv_data, fnct_WriteNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteNdwiAsciiGrid", 9,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdwiAsciiGrid", 8,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdwiAsciiGrid", 8,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdwiAsciiGrid", 9,
				   SQLITE_UTF8, 0,
				   fnct_WriteSectionNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdwiAsciiGrid", 9,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "WriteSectionNdwiAsciiGrid", 10,
				   SQLITE_UTF8, 0,
				   fnct_WriteSectionNdwiAsciiGrid, 0, 0);
	  sqlite3_create_function (db, "RL2_WriteSectionNdwiAsciiGrid", 10,
				   SQLITE_UTF8, priv_data,
				   fnct_WriteSectionNdwiAsciiGrid, 0, 0);
      }
}

#ifndef LOADABLE_EXTENSION

static void
rl2_splash_screen (int verbose)
................................................................................
    register_rl2_sql_functions (db, priv_data);
    *pzErrMsg = NULL;
    return 0;
}

#if !(defined _WIN32) || defined(__MINGW32__)
/* MSVC is unable to understand this declaration */
__attribute__((visibility ("default")))
#endif
     RL2_DECLARE int
	 sqlite3_modrasterlite_init (sqlite3 * db, char **pzErrMsg,
				     const sqlite3_api_routines * pApi)
{
/* SQLite invokes this routine once when it dynamically loads the extension. */
    return init_rl2_extension (db, pzErrMsg, pApi);
}

#endif

Changes to src/rl2sqlaux.c.

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
....
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
....
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
....
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
....
8948
8949
8950
8951
8952
8953
8954
8955


8956
8957

8958
8959
8960
8961
8962
8963
8964
....
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
....
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
....
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
....
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
....
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
....
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
....
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
....
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
....
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604








































9605




















9606

9607
9608
9609
9610
9611
9612
9613
    const char *style_name;
    const unsigned char *xml_style;
    int with_nodes;
    int with_edges_or_links;
    int with_faces;
    int with_edge_or_link_seeds;
    int with_face_seeds;
    int has_labels;
    struct aux_raster_image *output;
};

#define RL2_UNUSED() if (argc || argv) argc = argc;

RL2_PRIVATE int
get_coverage_sample_bands (sqlite3 * sqlite, const char *db_prefix,
................................................................................
    int j;
    int ret;
    int reproject_on_the_fly;
    int has_extra_columns;
    rl2VariantArrayPtr variant = NULL;
    rl2GraphicsContextPtr ctx = NULL;
    rl2GraphicsContextPtr ctx_labels = NULL;
    int has_labels = 0;
    unsigned char *rgb = NULL;
    unsigned char *alpha = NULL;
    int half_transparent;
    int is_topogeo = 0;
    int is_toponet = 0;
    int which = RL2_CANVAS_UNKNOWN_CTX;

................................................................................
		  }
	    }
	  else
	    {
		/* using the Canvas Base Graphics Context */
		ctx = rl2_get_canvas_ctx (canvas, RL2_CANVAS_BASE_CTX);
	    }
	  has_labels = rl2_style_has_labels (lyr_stl);
	  if (has_labels)
	    {
		ctx_labels = rl2_get_canvas_ctx (canvas, RL2_CANVAS_LABELS_CTX);
		if (ctx_labels == NULL)
		    goto error;
	    }
	  if (ctx == NULL)
	      goto error;

	  /* composing the SQL query */
	  toponame = sqlite3_mprintf ("%s", lyr->f_table_name);
	  len = strlen (lyr->f_table_name);
	  if (len > 5)
................................................................................
					break;
				    };
			      }
			}
		      if (geom != NULL)
			{
			    /* drawing a styled Feature */
			    int has_labels;
			    int scale_forbidden = 0;
			    symbolizer = NULL;
			    if (lyr_stl != NULL)
				symbolizer =
				    rl2_get_symbolizer_from_feature_type_style
				    (lyr_stl, scale, variant, &scale_forbidden);
			    if (!scale_forbidden)
				rl2_draw_vector_feature (ctx, ctx_labels,
							 sqlite, priv_data,
							 symbolizer, height,
							 minx, miny, maxx, maxy,
							 x_res, y_res, geom,
							 variant, &has_labels);
			    if (has_labels)
				aux->has_labels = 1;
			    rl2_destroy_geometry (geom);
			}
		  }
	    }
	  sqlite3_finalize (stmt);
	  stmt = NULL;

................................................................................
    rl2_destroy_multi_layer (multi);
    multi = NULL;
    if (lyr_stl != NULL)
	rl2_destroy_feature_type_style (lyr_stl);
    if (variant != NULL)
	rl2_destroy_variant_array (variant);
    if (stmt != NULL)
	sqlite3_finalize (stmt);


    aux->output->img = NULL;
    aux->output->img_size = 0;

    return RL2_ERROR;
}

static int
do_check_topogeo (sqlite3 * sqlite, const char *db_prefix, const char *coverage)
{
/* checking for a TopoGeo Coverage */
................................................................................
    aux.style_name = style_name;
    aux.xml_style = NULL;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.has_labels = 0;
    aux.output = malloc (sizeof (struct aux_raster_image));
    aux.output->bg_red = 255;
    aux.output->bg_green = 255;
    aux.output->bg_blue = 255;
    aux.output->transparent = transparent;
    aux.output->format = format;
    aux.output->quality = quality;
................................................................................
	  ctx_faces = rl2_graph_create_context (data, width, height);
	  if (ctx_faces == NULL)
	      goto error;
	  ctx_face_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_face_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_topology_canvas (ctx, ctx_labels, ctx_nodes, ctx_edges,
					  ctx_faces, ctx_edge_seeds,
					  ctx_face_seeds);
      }
    else if (is_toponet)
      {
	  /* Network canvas */
	  ctx_nodes = rl2_graph_create_context (data, width, height);
................................................................................
	  ctx_links = rl2_graph_create_context (data, width, height);
	  if (ctx_links == NULL)
	      goto error;
	  ctx_link_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_link_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_network_canvas (ctx, ctx_labels, ctx_nodes, ctx_links,
					 ctx_link_seeds);
      }
    else
      {
	  /* generic Vector canvas */
	  aux.canvas = rl2_create_vector_canvas (ctx, ctx_labels);
      }
    if (aux.canvas == NULL)
	goto error;
    if (!transparent)
      {
	  /* parsing the background color */
	  bg_alpha = 255;
................................................................................
    aux.style_name = "external_style";
    aux.xml_style = xml_style;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.has_labels = 0;
    aux.output = malloc (sizeof (struct aux_raster_image));
    aux.output->bg_red = 255;
    aux.output->bg_green = 255;
    aux.output->bg_blue = 255;
    aux.output->transparent = transparent;
    aux.output->format = format;
    aux.output->quality = quality;
................................................................................
	  ctx_faces = rl2_graph_create_context (data, width, height);
	  if (ctx_faces == NULL)
	      goto error;
	  ctx_face_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_face_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_topology_canvas (ctx, ctx_labels, ctx_nodes, ctx_edges,
					  ctx_faces, ctx_edge_seeds,
					  ctx_face_seeds);
      }
    else if (is_toponet)
      {
	  /* Network canvas */
	  ctx_nodes = rl2_graph_create_context (data, width, height);
................................................................................
	  ctx_links = rl2_graph_create_context (data, width, height);
	  if (ctx_links == NULL)
	      goto error;
	  ctx_link_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_link_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_network_canvas (ctx, ctx_labels, ctx_nodes, ctx_links,
					 ctx_link_seeds);
      }
    else
      {
	  /* generic Vector canvas */
	  aux.canvas = rl2_create_vector_canvas (ctx, ctx_labels);
      }
    if (aux.canvas == NULL)
	goto error;
    if (!transparent)
      {
	  /* parsing the background color */
	  bg_alpha = 255;
................................................................................

RL2_DECLARE int
rl2_map_image_paint_from_vector (sqlite3 * sqlite, const void *data,
				 rl2CanvasPtr canvas, const char *db_prefix,
				 const char *cvg_name,
				 const unsigned char *blob, int blob_sz,
				 int reaspect, const char *style_name,
				 const unsigned char *xml_style,
				 int *has_labels)
{
/* rendering a Map Image from a Vector Coverage - Graphics Context */
    struct aux_vector_render aux;
    rl2GraphicsContextPtr ctx;
    int width;
    int height;
    int ret;
................................................................................
    aux.xml_style = xml_style;
    aux.output = NULL;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.has_labels = 0;
    ret = do_paint_map_from_vector (&aux);
    if (aux.has_labels)
	*has_labels = 1;
    else
	*has_labels = 0;
    return ret;
}

RL2_DECLARE int
rl2_map_image_paint_from_vector_ex (sqlite3 * sqlite, const void *data,
				    rl2CanvasPtr canvas, const char *db_prefix,
				    const char *cvg_name,
				    const unsigned char *blob, int blob_sz,
				    int reaspect, const char *style_name,
				    const unsigned char *xml_style,
				    int with_nodes, int with_edges_or_links,
				    int with_faces, int with_edge_or_link_seeds,
				    int with_face_seeds, int *has_labels)
{
/* rendering a Map Image from a Vector Coverage - Graphics Context - extended */
    struct aux_vector_render aux;
    rl2GraphicsContextPtr ctx;
    int width;
    int height;
    int ret;
................................................................................
    aux.xml_style = xml_style;
    aux.output = NULL;
    aux.with_nodes = with_nodes;
    aux.with_edges_or_links = with_edges_or_links;
    aux.with_faces = with_faces;
    aux.with_edge_or_link_seeds = with_edge_or_link_seeds;
    aux.with_face_seeds = with_face_seeds;
    aux.has_labels = 0;
    ret = do_paint_map_from_vector (&aux);
    if (aux.has_labels)
	*has_labels = 1;








































    else




















	*has_labels = 0;

    return ret;
}

static int
sniff_valid_xml (const char *str)
{
/* sniffing if a generic text string seems to be valid XML */







|







 







<







 







<
<
<
<
<
<
<







 







<







|
|



|
|
<







 







|
>
>
|
|
>







 







|







 







|







 







|





|







 







|







 







|







 







|





|







 







|
<







 







|

<
<
<
<












|







 







|

|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
....
7966
7967
7968
7969
7970
7971
7972

7973
7974
7975
7976
7977
7978
7979
....
8204
8205
8206
8207
8208
8209
8210







8211
8212
8213
8214
8215
8216
8217
....
8700
8701
8702
8703
8704
8705
8706

8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720

8721
8722
8723
8724
8725
8726
8727
....
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
....
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
....
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
....
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
....
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
....
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
....
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
....
9462
9463
9464
9465
9466
9467
9468
9469

9470
9471
9472
9473
9474
9475
9476
....
9515
9516
9517
9518
9519
9520
9521
9522
9523




9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
....
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591

9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
    const char *style_name;
    const unsigned char *xml_style;
    int with_nodes;
    int with_edges_or_links;
    int with_faces;
    int with_edge_or_link_seeds;
    int with_face_seeds;
    int mode_labels;
    struct aux_raster_image *output;
};

#define RL2_UNUSED() if (argc || argv) argc = argc;

RL2_PRIVATE int
get_coverage_sample_bands (sqlite3 * sqlite, const char *db_prefix,
................................................................................
    int j;
    int ret;
    int reproject_on_the_fly;
    int has_extra_columns;
    rl2VariantArrayPtr variant = NULL;
    rl2GraphicsContextPtr ctx = NULL;
    rl2GraphicsContextPtr ctx_labels = NULL;

    unsigned char *rgb = NULL;
    unsigned char *alpha = NULL;
    int half_transparent;
    int is_topogeo = 0;
    int is_toponet = 0;
    int which = RL2_CANVAS_UNKNOWN_CTX;

................................................................................
		  }
	    }
	  else
	    {
		/* using the Canvas Base Graphics Context */
		ctx = rl2_get_canvas_ctx (canvas, RL2_CANVAS_BASE_CTX);
	    }







	  if (ctx == NULL)
	      goto error;

	  /* composing the SQL query */
	  toponame = sqlite3_mprintf ("%s", lyr->f_table_name);
	  len = strlen (lyr->f_table_name);
	  if (len > 5)
................................................................................
					break;
				    };
			      }
			}
		      if (geom != NULL)
			{
			    /* drawing a styled Feature */

			    int scale_forbidden = 0;
			    symbolizer = NULL;
			    if (lyr_stl != NULL)
				symbolizer =
				    rl2_get_symbolizer_from_feature_type_style
				    (lyr_stl, scale, variant, &scale_forbidden);
			    if (!scale_forbidden)
			    {
				rl2_draw_vector_feature (ctx, sqlite, priv_data,
							 symbolizer, height,
							 minx, miny, maxx, maxy,
							 x_res, y_res, geom,
							 variant, aux->mode_labels);
						 }

			    rl2_destroy_geometry (geom);
			}
		  }
	    }
	  sqlite3_finalize (stmt);
	  stmt = NULL;

................................................................................
    rl2_destroy_multi_layer (multi);
    multi = NULL;
    if (lyr_stl != NULL)
	rl2_destroy_feature_type_style (lyr_stl);
    if (variant != NULL)
	rl2_destroy_variant_array (variant);
    if (stmt != NULL)
		sqlite3_finalize (stmt);
	if (aux->output != NULL)
	{
		aux->output->img = NULL;
		aux->output->img_size = 0;
	}
    return RL2_ERROR;
}

static int
do_check_topogeo (sqlite3 * sqlite, const char *db_prefix, const char *coverage)
{
/* checking for a TopoGeo Coverage */
................................................................................
    aux.style_name = style_name;
    aux.xml_style = NULL;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.mode_labels = 0;
    aux.output = malloc (sizeof (struct aux_raster_image));
    aux.output->bg_red = 255;
    aux.output->bg_green = 255;
    aux.output->bg_blue = 255;
    aux.output->transparent = transparent;
    aux.output->format = format;
    aux.output->quality = quality;
................................................................................
	  ctx_faces = rl2_graph_create_context (data, width, height);
	  if (ctx_faces == NULL)
	      goto error;
	  ctx_face_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_face_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_topology_canvas (ctx, ctx_nodes, ctx_edges,
					  ctx_faces, ctx_edge_seeds,
					  ctx_face_seeds);
      }
    else if (is_toponet)
      {
	  /* Network canvas */
	  ctx_nodes = rl2_graph_create_context (data, width, height);
................................................................................
	  ctx_links = rl2_graph_create_context (data, width, height);
	  if (ctx_links == NULL)
	      goto error;
	  ctx_link_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_link_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_network_canvas (ctx, ctx_nodes, ctx_links,
					 ctx_link_seeds);
      }
    else
      {
	  /* generic Vector canvas */
	  aux.canvas = rl2_create_vector_canvas (ctx);
      }
    if (aux.canvas == NULL)
	goto error;
    if (!transparent)
      {
	  /* parsing the background color */
	  bg_alpha = 255;
................................................................................
    aux.style_name = "external_style";
    aux.xml_style = xml_style;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.mode_labels = 0;
    aux.output = malloc (sizeof (struct aux_raster_image));
    aux.output->bg_red = 255;
    aux.output->bg_green = 255;
    aux.output->bg_blue = 255;
    aux.output->transparent = transparent;
    aux.output->format = format;
    aux.output->quality = quality;
................................................................................
	  ctx_faces = rl2_graph_create_context (data, width, height);
	  if (ctx_faces == NULL)
	      goto error;
	  ctx_face_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_face_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_topology_canvas (ctx, ctx_nodes, ctx_edges,
					  ctx_faces, ctx_edge_seeds,
					  ctx_face_seeds);
      }
    else if (is_toponet)
      {
	  /* Network canvas */
	  ctx_nodes = rl2_graph_create_context (data, width, height);
................................................................................
	  ctx_links = rl2_graph_create_context (data, width, height);
	  if (ctx_links == NULL)
	      goto error;
	  ctx_link_seeds = rl2_graph_create_context (data, width, height);
	  if (ctx_link_seeds == NULL)
	      goto error;
	  aux.canvas =
	      rl2_create_network_canvas (ctx, ctx_nodes, ctx_links,
					 ctx_link_seeds);
      }
    else
      {
	  /* generic Vector canvas */
	  aux.canvas = rl2_create_vector_canvas (ctx);
      }
    if (aux.canvas == NULL)
	goto error;
    if (!transparent)
      {
	  /* parsing the background color */
	  bg_alpha = 255;
................................................................................

RL2_DECLARE int
rl2_map_image_paint_from_vector (sqlite3 * sqlite, const void *data,
				 rl2CanvasPtr canvas, const char *db_prefix,
				 const char *cvg_name,
				 const unsigned char *blob, int blob_sz,
				 int reaspect, const char *style_name,
				 const unsigned char *xml_style)

{
/* rendering a Map Image from a Vector Coverage - Graphics Context */
    struct aux_vector_render aux;
    rl2GraphicsContextPtr ctx;
    int width;
    int height;
    int ret;
................................................................................
    aux.xml_style = xml_style;
    aux.output = NULL;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.mode_labels = 0;
    ret = do_paint_map_from_vector (&aux);




    return ret;
}

RL2_DECLARE int
rl2_map_image_paint_from_vector_ex (sqlite3 * sqlite, const void *data,
				    rl2CanvasPtr canvas, const char *db_prefix,
				    const char *cvg_name,
				    const unsigned char *blob, int blob_sz,
				    int reaspect, const char *style_name,
				    const unsigned char *xml_style,
				    int with_nodes, int with_edges_or_links,
				    int with_faces, int with_edge_or_link_seeds,
				    int with_face_seeds)
{
/* rendering a Map Image from a Vector Coverage - Graphics Context - extended */
    struct aux_vector_render aux;
    rl2GraphicsContextPtr ctx;
    int width;
    int height;
    int ret;
................................................................................
    aux.xml_style = xml_style;
    aux.output = NULL;
    aux.with_nodes = with_nodes;
    aux.with_edges_or_links = with_edges_or_links;
    aux.with_faces = with_faces;
    aux.with_edge_or_link_seeds = with_edge_or_link_seeds;
    aux.with_face_seeds = with_face_seeds;
    aux.mode_labels = 0;
    ret = do_paint_map_from_vector (&aux);
    return ret;

}

RL2_DECLARE int
rl2_map_image_paint_labels (sqlite3 * sqlite, const void *data,
				 rl2CanvasPtr canvas, const char *db_prefix,
				 const char *cvg_name,
				 const unsigned char *blob, int blob_sz,
				 int reaspect, const char *style_name,
				 const unsigned char *xml_style)
{
/* rendering Labels from a Vector Coverage - Graphics Context */
    struct aux_vector_render aux;
    rl2GraphicsContextPtr ctx;
    int width;
    int height;
    int ret;

    if (canvas == NULL)
	return RL2_ERROR;
    ctx = rl2_get_canvas_ctx (canvas, RL2_CANVAS_BASE_CTX);
    if (ctx == NULL)
	return RL2_ERROR;
    if (rl2_graph_context_get_dimensions (ctx, &width, &height) != RL2_OK)
	return RL2_ERROR;

    if (reaspect == 0)
      {
	  /* testing for consistent aspect ratios */
	  double aspect_org =
	      do_compute_bbox_aspect_ratio (sqlite, blob, blob_sz);
	  double aspect_dst = (double) width / (double) height;
	  double confidence = aspect_org / 100.0;
	  aspect_org = do_compute_bbox_aspect_ratio (sqlite, blob, blob_sz);
	  if (aspect_org < 0.0)
	      return RL2_ERROR;
	  aspect_dst = (double) width / (double) height;
	  confidence = aspect_org / 100.0;
	  if (aspect_dst >= (aspect_org - confidence)
	      && aspect_dst <= (aspect_org + confidence))
	      ;
	  else
	      return RL2_ERROR;
      }

    aux.sqlite = sqlite;
    aux.data = data;
    aux.canvas = canvas;
    aux.db_prefix = db_prefix;
    aux.cvg_name = cvg_name;
    aux.blob = blob;
    aux.blob_sz = blob_sz;
    aux.width = width;
    aux.height = height;
    aux.style_name = style_name;
    aux.xml_style = xml_style;
    aux.output = NULL;
    aux.with_nodes = 1;
    aux.with_edges_or_links = 1;
    aux.with_faces = 0;
    aux.with_edge_or_link_seeds = 1;
    aux.with_face_seeds = 1;
    aux.mode_labels = 1;
    ret = do_paint_map_from_vector (&aux);
    return ret;
}

static int
sniff_valid_xml (const char *str)
{
/* sniffing if a generic text string seems to be valid XML */

Added test/map_config.sqlite.

cannot compute difference between binary files

Changes to test/sql_stmt_security_tests/Makefile.am.

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
...
158
159
160
161
162
163
164




































165
166
167
168
169
170
171
	writesectionascii18.testcase \
	writesectionascii19.testcase \
	writesectionascii20.testcase \
	writendviascii1.testcase \
	writendviascii2.testcase \
	writendviascii3.testcase \
	writendviascii4.testcase \
	writendviascii5.testcase \
	writendviascii6.testcase \
	writendviascii7.testcase \
	writendviascii8.testcase \
	writendviascii9.testcase \
	writendviascii10.testcase \
	writendviascii11.testcase \
	writendviascii12.testcase \
	writendviascii13.testcase \
................................................................................
	writendviascii17.testcase \
	writendviascii18.testcase \
	writendviascii19.testcase \
	writesectionndviascii1.testcase \
	writesectionndviascii2.testcase \
	writesectionndviascii3.testcase \
	writesectionndviascii4.testcase \
	writesectionndviascii5.testcase \
	writesectionndviascii6.testcase \
	writesectionndviascii7.testcase \
	writesectionndviascii8.testcase \
	writesectionndviascii9.testcase \
	writesectionndviascii10.testcase \
	writesectionndviascii11.testcase \
	writesectionndviascii12.testcase \
	writesectionndviascii13.testcase \
................................................................................
	writesectionndviascii15.testcase \
	writesectionndviascii16.testcase \
	writesectionndviascii17.testcase \
	writesectionndviascii18.testcase \
	writesectionndviascii19.testcase \
	writesectionndviascii20.testcase \
	writesectionndviascii21.testcase \




































	writebandtiff1.testcase \
	writebandtiff2.testcase \
	writebandtiff3.testcase \
	writebandtiff4.testcase \
	writebandtiff5.testcase \
	writebandtiff6.testcase \
	writebandtiff7.testcase \







<
<







 







<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







122
123
124
125
126
127
128


129
130
131
132
133
134
135
...
139
140
141
142
143
144
145


146
147
148
149
150
151
152
...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
	writesectionascii18.testcase \
	writesectionascii19.testcase \
	writesectionascii20.testcase \
	writendviascii1.testcase \
	writendviascii2.testcase \
	writendviascii3.testcase \
	writendviascii4.testcase \


	writendviascii7.testcase \
	writendviascii8.testcase \
	writendviascii9.testcase \
	writendviascii10.testcase \
	writendviascii11.testcase \
	writendviascii12.testcase \
	writendviascii13.testcase \
................................................................................
	writendviascii17.testcase \
	writendviascii18.testcase \
	writendviascii19.testcase \
	writesectionndviascii1.testcase \
	writesectionndviascii2.testcase \
	writesectionndviascii3.testcase \
	writesectionndviascii4.testcase \


	writesectionndviascii7.testcase \
	writesectionndviascii8.testcase \
	writesectionndviascii9.testcase \
	writesectionndviascii10.testcase \
	writesectionndviascii11.testcase \
	writesectionndviascii12.testcase \
	writesectionndviascii13.testcase \
................................................................................
	writesectionndviascii15.testcase \
	writesectionndviascii16.testcase \
	writesectionndviascii17.testcase \
	writesectionndviascii18.testcase \
	writesectionndviascii19.testcase \
	writesectionndviascii20.testcase \
	writesectionndviascii21.testcase \
	writendwiascii1.testcase \
	writendwiascii2.testcase \
	writendwiascii3.testcase \
	writendwiascii4.testcase \
	writendwiascii7.testcase \
	writendwiascii8.testcase \
	writendwiascii9.testcase \
	writendwiascii10.testcase \
	writendwiascii11.testcase \
	writendwiascii12.testcase \
	writendwiascii13.testcase \
	writendwiascii14.testcase \
	writendwiascii15.testcase \
	writendwiascii16.testcase \
	writendwiascii17.testcase \
	writendwiascii18.testcase \
	writendwiascii19.testcase \
	writesectionndwiascii1.testcase \
	writesectionndwiascii2.testcase \
	writesectionndwiascii3.testcase \
	writesectionndwiascii4.testcase \
	writesectionndwiascii7.testcase \
	writesectionndwiascii8.testcase \
	writesectionndwiascii9.testcase \
	writesectionndwiascii10.testcase \
	writesectionndwiascii11.testcase \
	writesectionndwiascii12.testcase \
	writesectionndwiascii13.testcase \
	writesectionndwiascii14.testcase \
	writesectionndwiascii15.testcase \
	writesectionndwiascii16.testcase \
	writesectionndwiascii17.testcase \
	writesectionndwiascii18.testcase \
	writesectionndwiascii19.testcase \
	writesectionndwiascii20.testcase \
	writesectionndwiascii21.testcase \
	writebandtiff1.testcase \
	writebandtiff2.testcase \
	writebandtiff3.testcase \
	writebandtiff4.testcase \
	writebandtiff5.testcase \
	writebandtiff6.testcase \
	writebandtiff7.testcase \

Changes to test/sql_stmt_security_tests/Makefile.in.

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
...
433
434
435
436
437
438
439




































440
441
442
443
444
445
446
	writesectionascii18.testcase \
	writesectionascii19.testcase \
	writesectionascii20.testcase \
	writendviascii1.testcase \
	writendviascii2.testcase \
	writendviascii3.testcase \
	writendviascii4.testcase \
	writendviascii5.testcase \
	writendviascii6.testcase \
	writendviascii7.testcase \
	writendviascii8.testcase \
	writendviascii9.testcase \
	writendviascii10.testcase \
	writendviascii11.testcase \
	writendviascii12.testcase \
	writendviascii13.testcase \
................................................................................
	writendviascii17.testcase \
	writendviascii18.testcase \
	writendviascii19.testcase \
	writesectionndviascii1.testcase \
	writesectionndviascii2.testcase \
	writesectionndviascii3.testcase \
	writesectionndviascii4.testcase \
	writesectionndviascii5.testcase \
	writesectionndviascii6.testcase \
	writesectionndviascii7.testcase \
	writesectionndviascii8.testcase \
	writesectionndviascii9.testcase \
	writesectionndviascii10.testcase \
	writesectionndviascii11.testcase \
	writesectionndviascii12.testcase \
	writesectionndviascii13.testcase \
................................................................................
	writesectionndviascii15.testcase \
	writesectionndviascii16.testcase \
	writesectionndviascii17.testcase \
	writesectionndviascii18.testcase \
	writesectionndviascii19.testcase \
	writesectionndviascii20.testcase \
	writesectionndviascii21.testcase \




































	writebandtiff1.testcase \
	writebandtiff2.testcase \
	writebandtiff3.testcase \
	writebandtiff4.testcase \
	writebandtiff5.testcase \
	writebandtiff6.testcase \
	writebandtiff7.testcase \







<
<







 







<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







397
398
399
400
401
402
403


404
405
406
407
408
409
410
...
414
415
416
417
418
419
420


421
422
423
424
425
426
427
...
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
	writesectionascii18.testcase \
	writesectionascii19.testcase \
	writesectionascii20.testcase \
	writendviascii1.testcase \
	writendviascii2.testcase \
	writendviascii3.testcase \
	writendviascii4.testcase \


	writendviascii7.testcase \
	writendviascii8.testcase \
	writendviascii9.testcase \
	writendviascii10.testcase \
	writendviascii11.testcase \
	writendviascii12.testcase \
	writendviascii13.testcase \
................................................................................
	writendviascii17.testcase \
	writendviascii18.testcase \
	writendviascii19.testcase \
	writesectionndviascii1.testcase \
	writesectionndviascii2.testcase \
	writesectionndviascii3.testcase \
	writesectionndviascii4.testcase \


	writesectionndviascii7.testcase \
	writesectionndviascii8.testcase \
	writesectionndviascii9.testcase \
	writesectionndviascii10.testcase \
	writesectionndviascii11.testcase \
	writesectionndviascii12.testcase \
	writesectionndviascii13.testcase \
................................................................................
	writesectionndviascii15.testcase \
	writesectionndviascii16.testcase \
	writesectionndviascii17.testcase \
	writesectionndviascii18.testcase \
	writesectionndviascii19.testcase \
	writesectionndviascii20.testcase \
	writesectionndviascii21.testcase \
	writendwiascii1.testcase \
	writendwiascii2.testcase \
	writendwiascii3.testcase \
	writendwiascii4.testcase \
	writendwiascii7.testcase \
	writendwiascii8.testcase \
	writendwiascii9.testcase \
	writendwiascii10.testcase \
	writendwiascii11.testcase \
	writendwiascii12.testcase \
	writendwiascii13.testcase \
	writendwiascii14.testcase \
	writendwiascii15.testcase \
	writendwiascii16.testcase \
	writendwiascii17.testcase \
	writendwiascii18.testcase \
	writendwiascii19.testcase \
	writesectionndwiascii1.testcase \
	writesectionndwiascii2.testcase \
	writesectionndwiascii3.testcase \
	writesectionndwiascii4.testcase \
	writesectionndwiascii7.testcase \
	writesectionndwiascii8.testcase \
	writesectionndwiascii9.testcase \
	writesectionndwiascii10.testcase \
	writesectionndwiascii11.testcase \
	writesectionndwiascii12.testcase \
	writesectionndwiascii13.testcase \
	writesectionndwiascii14.testcase \
	writesectionndwiascii15.testcase \
	writesectionndwiascii16.testcase \
	writesectionndwiascii17.testcase \
	writesectionndwiascii18.testcase \
	writesectionndwiascii19.testcase \
	writesectionndwiascii20.testcase \
	writesectionndwiascii21.testcase \
	writebandtiff1.testcase \
	writebandtiff2.testcase \
	writebandtiff3.testcase \
	writebandtiff4.testcase \
	writebandtiff5.testcase \
	writebandtiff6.testcase \
	writebandtiff7.testcase \

Changes to test/sql_stmt_security_tests/writendviascii1.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Coverage
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid('main', NULL, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid('main', NULL, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Coverage
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid('main', NULL, './test.asc', 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid('main', NULL, './test.asc', 1024, 1024, MakePoint(1, 1), 1)
-1

Changes to test/sql_stmt_security_tests/writendviascii10.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL is-centered
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, NULL)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL is-centered
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL)
-1

Changes to test/sql_stmt_security_tests/writendviascii11.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL decimal-digits
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, NULL)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL decimal-digits
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL)
-1

Changes to test/sql_stmt_security_tests/writendviascii12.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - not existing coverage (1)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - not existing coverage (1)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writendviascii13.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - not existing coverage (2)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - not existing coverage (2)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writendviascii14.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid width (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 4, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 4, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid width (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writendviascii15.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid width (too big)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1000004, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1000004, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid width (too big)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writendviascii16.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid height (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid height (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writendviascii17.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid height (too big)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid height (too big)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writendviascii18.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid decimal precision (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, -1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, -1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - invalid decimal precision (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1)
-1

Changes to test/sql_stmt_security_tests/writendviascii19.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - Int DbPrefix
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(1, 'alpha', './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 4);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(1, 'alpha', './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 4)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - Int DbPrefix
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(1, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 4);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(1, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 4)
-1

Changes to test/sql_stmt_security_tests/writendviascii2.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Path
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid('MAIN', 'alpha', NULL, 1024, 1024, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid('MAIN', 'alpha', NULL, 1024, 1024, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Path
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid('MAIN', 'alpha', NULL, 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid('MAIN', 'alpha', NULL, 1024, 1024, MakePoint(1, 1), 1)
-1

Changes to test/sql_stmt_security_tests/writendviascii3.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Width
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', NULL, 1024, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', NULL, 1024, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Width
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', NULL, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', NULL, 1024, MakePoint(1, 1), 1)
-1

Changes to test/sql_stmt_security_tests/writendviascii4.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Height
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, NULL, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, NULL, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Height
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, NULL, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, NULL, MakePoint(1, 1), 1)
-1

Deleted test/sql_stmt_security_tests/writendviascii5.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL red band
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, NULL, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, NULL, 3, MakePoint(1, 1), 1)
-1
<
<
<
<
<
<
<














Deleted test/sql_stmt_security_tests/writendviascii6.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL NIR band
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, NULL, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, NULL, MakePoint(1, 1), 1)
-1
<
<
<
<
<
<
<














Changes to test/sql_stmt_security_tests/writendviascii7.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Geometry
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, NULL, 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, NULL, 0.5)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL Geometry
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, NULL, 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, NULL, 0.5)
-1

Changes to test/sql_stmt_security_tests/writendviascii8.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - Invalid BLOB Geometry
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, zeroblob(100), 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, zeroblob(100), 0.5)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - Invalid BLOB Geometry
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, zeroblob(100), 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, zeroblob(100), 0.5)
-1

Changes to test/sql_stmt_security_tests/writendviascii9.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL resolution
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), NULL)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviAsciiGrid - NULL resolution
:memory: #use in-memory database
SELECT RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdviAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), NULL)
-1

Added test/sql_stmt_security_tests/writendwiascii1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL Coverage
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid('main', NULL, './test.asc', 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid('main', NULL, './test.asc', 1024, 1024, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writendwiascii10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL is-centered
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL)
-1

Added test/sql_stmt_security_tests/writendwiascii11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL decimal-digits
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL)
-1

Added test/sql_stmt_security_tests/writendwiascii12.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - not existing coverage (1)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2)
-1

Added test/sql_stmt_security_tests/writendwiascii13.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - not existing coverage (2)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writendwiascii14.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - invalid width (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writendwiascii15.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - invalid width (too big)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writendwiascii16.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - invalid height (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writendwiascii17.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - invalid height (too big)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writendwiascii18.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - invalid decimal precision (too small)
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1)
-1

Added test/sql_stmt_security_tests/writendwiascii19.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - Int DbPrefix
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(1, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 4);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(1, 'alpha', './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 4)
-1

Added test/sql_stmt_security_tests/writendwiascii2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL Path
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid('MAIN', 'alpha', NULL, 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid('MAIN', 'alpha', NULL, 1024, 1024, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writendwiascii3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL Width
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', NULL, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', NULL, 1024, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writendwiascii4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL Height
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, NULL, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, NULL, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writendwiascii7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL Geometry
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, NULL, 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, NULL, 0.5)
-1

Added test/sql_stmt_security_tests/writendwiascii8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - Invalid BLOB Geometry
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, zeroblob(100), 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, zeroblob(100), 0.5)
-1

Added test/sql_stmt_security_tests/writendwiascii9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiAsciiGrid - NULL resolution
:memory: #use in-memory database
SELECT RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteNdwiAsciiGrid(NULL, 'alpha', './test.asc', 1024, 1024, MakePoint(1, 1), NULL)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii1.testcase.

1
2
3
4
5
6
7
RL2_WriteNdviSectionAsciiGrid - NULL Coverage
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid('main', NULL, 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid('main', NULL, 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteNdviSectionAsciiGrid - NULL Coverage
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid('main', NULL, 1, './test.asc', 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid('main', NULL, 1, './test.asc', 1024, 1024, MakePoint(1, 1), 1)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii10.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL is-centered
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, NULL)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL is-centered
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii11.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL decimal-digits
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, NULL)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL decimal-digits
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii12.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - not existing coverage (1)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), 0.5, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - not existing coverage (1)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii13.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - not existing coverage (2)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - not existing coverage (2)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii14.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid width (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 4, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 4, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid width (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii15.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid width (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1000004, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1000004, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid width (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii16.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid height (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid height (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii17.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid height (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid height (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii18.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid decimal precision (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, -1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, -1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid decimal precision (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii19.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid decimal precision (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - invalid decimal precision (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii2.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Path
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid('MAIN', 'alpha', 1, NULL, 1024, 1024, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid('MAIN', 'alpha', 1, NULL, 1024, 1024, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Path
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid('MAIN', 'alpha', 1, NULL, 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid('MAIN', 'alpha', 1, NULL, 1024, 1024, MakePoint(1, 1), 1)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii20.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Section
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', NULL, './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', NULL, './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Section
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', NULL, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', NULL, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii21.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - Int DbPrefix
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(1, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(1, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - Int DbPrefix
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(1, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(1, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii3.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Width
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', NULL, 1024, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', NULL, 1024, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Width
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', NULL, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', NULL, 1024, MakePoint(1, 1), 1)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii4.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Height
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, NULL, 0, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, NULL, 0, 3, MakePoint(1, 1), 1)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Height
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, NULL, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, NULL, MakePoint(1, 1), 1)
-1

Deleted test/sql_stmt_security_tests/writesectionndviascii5.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL red band
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, NULL, 3, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, NULL, 3, MakePoint(1, 1), 1)
-1
<
<
<
<
<
<
<














Deleted test/sql_stmt_security_tests/writesectionndviascii6.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL NIR band
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, NULL, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, NULL, MakePoint(1, 1), 1)
-1
<
<
<
<
<
<
<














Changes to test/sql_stmt_security_tests/writesectionndviascii7.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Geometry
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, NULL, 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, NULL, 0.5)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL Geometry
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, NULL, 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, NULL, 0.5)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii8.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - Invalid BLOB Geometry
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, zeroblob(100), 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, zeroblob(100), 0.5)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - Invalid BLOB Geometry
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, zeroblob(100), 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, zeroblob(100), 0.5)
-1

Changes to test/sql_stmt_security_tests/writesectionndviascii9.testcase.

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL resolution
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, 0, 3, MakePoint(1, 1), NULL)
-1


|


|

1
2
3
4
5
6
7
RL2_WriteSectionNdviAsciiGrid - NULL resolution
:memory: #use in-memory database
SELECT RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdviAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), NULL)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii1.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteNdwiSectionAsciiGrid - NULL Coverage
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid('main', NULL, 1, './test.asc', 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid('main', NULL, 1, './test.asc', 1024, 1024, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii10.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL is-centered
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, NULL)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii11.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL decimal-digits
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, NULL)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii12.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - not existing coverage (1)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), 0.5, 1, 2)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii13.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - not existing coverage (2)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii14.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - invalid width (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 4, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii15.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - invalid width (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1000004, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii16.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - invalid height (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii17.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - invalid height (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 2)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii18.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - invalid decimal precision (too small)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, -1)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii19.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - invalid decimal precision (too big)
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1000000, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii2.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL Path
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid('MAIN', 'alpha', 1, NULL, 1024, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid('MAIN', 'alpha', 1, NULL, 1024, 1024, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii20.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL Section
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', NULL, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', NULL, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii21.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - Int DbPrefix
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(1, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(1, 'alpha', 1, './test.asc', 1024, 1024, BuildMbr(1, 1, 10, 10), 1, 1, 50)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii3.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL Width
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', NULL, 1024, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', NULL, 1024, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii4.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL Height
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, NULL, MakePoint(1, 1), 1);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, NULL, MakePoint(1, 1), 1)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii7.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL Geometry
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, NULL, 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, NULL, 0.5)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii8.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - Invalid BLOB Geometry
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, zeroblob(100), 0.5);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, zeroblob(100), 0.5)
-1

Added test/sql_stmt_security_tests/writesectionndwiascii9.testcase.















>
>
>
>
>
>
>
1
2
3
4
5
6
7
RL2_WriteSectionNdwiAsciiGrid - NULL resolution
:memory: #use in-memory database
SELECT RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), NULL);
1 # rows (not including the header row)
1 # columns
RL2_WriteSectionNdwiAsciiGrid(NULL, 'alpha', 1, './test.asc', 1024, 1024, MakePoint(1, 1), NULL)
-1

Changes to test/test_map_config.c.

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
...
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
...
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
...
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
...
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
...
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
....
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
....
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
....
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
....
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
....
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
....
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
....
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
....
1877
1878
1879
1880
1881
1882
1883


















































































































































































































1884
1885
1886
1887
1888
1889
1890
....
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
....
1919
1920
1921
1922
1923
1924
1925



1926
1927
		  }
		if (lyr->raster_style->contrast_enhancement->gamma_value !=
		    1.57)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected ContrastEnhancement GammaValue %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->raster_style->
			       contrast_enhancement->gamma_value);
		      ret = -19;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "raster_8") == 0)
	    {
................................................................................
		if (lyr->raster_style->channel_selection->rgb == 0
		    || lyr->raster_style->channel_selection->green_channel != 1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected ChannelSelection RGB=%d Green=%d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->raster_style->channel_selection->rgb,
			       lyr->raster_style->
			       channel_selection->green_channel);
		      ret = -23;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "raster_9") == 0)
	    {
................................................................................
		if (lyr->raster_style->channel_selection->rgb != 0
		    || lyr->raster_style->channel_selection->gray_channel != 4)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected ChannelSelection RGB=%d Green=%d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->raster_style->channel_selection->rgb,
			       lyr->raster_style->
			       channel_selection->gray_channel);
		      ret = -27;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "wms_layer_2") == 0)
	    {
................................................................................
		if (strcmp
		    (lyr->topology_internal_style->style_internal_name,
		     "topology_style_1") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected Internal Style Name \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->
			       topology_internal_style->style_internal_name);
		      ret = -57;
		      goto stop;
		  }
		if (lyr->topology_internal_style->show_faces == 0
		    || lyr->topology_internal_style->show_edges == 0
		    || lyr->topology_internal_style->show_nodes == 0
		    || lyr->topology_internal_style->show_edge_seeds == 0
................................................................................
		if (strcmp
		    (lyr->network_internal_style->style_internal_name,
		     "network_style_1") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected Internal Style Name \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->
			       network_internal_style->style_internal_name);
		      ret = -62;
		      goto stop;
		  }
		if (lyr->network_internal_style->show_links == 0 ||
		    lyr->network_internal_style->show_nodes == 0
		    || lyr->network_internal_style->show_link_seeds == 0)
		  {
................................................................................
		    lyr->vector_style->point_sym->mark->stroke->green != 0x03 ||
		    lyr->vector_style->point_sym->mark->stroke->blue != 0xfa)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PointSymbolizerMarkStroke #%02x%02x%02x !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->point_sym->mark->stroke->red,
			       lyr->vector_style->point_sym->mark->
			       stroke->green,
			       lyr->vector_style->point_sym->mark->
			       stroke->blue);
		      ret = -71;
		      goto stop;
		  }
		if (lyr->vector_style->point_sym->opacity != 0.75)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PointSymbolizerOpacity %1.2f !!\n",
................................................................................
		      goto stop;
		  }
		if (lyr->vector_style->first_line_sym->stroke->opacity != 0.66)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected LineSymbolizerStrokeOpacity %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->first_line_sym->
			       stroke->opacity);
		      ret = -82;
		      goto stop;
		  }
		if (lyr->vector_style->first_line_sym->stroke->width != 8.52)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected LineSymbolizerStrokeWidth %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->first_line_sym->
			       stroke->width);
		      ret = -83;
		      goto stop;
		  }
		if (lyr->vector_style->first_line_sym->stroke->dot_style != 4)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected LineSymbolizerStrokeDotStyle %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->first_line_sym->
			       stroke->dot_style);
		      ret = -84;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "topology_2") == 0)
	    {
................................................................................
		if (strcmp
		    (lyr->vector_style->polygon_sym->fill->graphic->resource,
		     "http://www.utopia.gov/stdbrush_crossdiag.png") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerFillGraphicResource \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->fill->graphic->
			       resource);
		      ret = -94;
		      goto stop;
		  }
		if (strcmp
		    (lyr->vector_style->polygon_sym->fill->graphic->format,
		     "image/png") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerFillGraphicFormat \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->fill->graphic->
			       format);
		      ret = -95;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->fill->graphic->color ==
		    NULL)
		  {
		      fprintf (stderr,
................................................................................
			       "Layer <%s><%s> unexpected NULL PolygonSymbolizerFillGraphicRemapColor !!\n",
			       lyr->prefix, lyr->name);
		      ret = -96;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->fill->graphic->color->red !=
		    0xfb
		    || lyr->vector_style->polygon_sym->fill->graphic->color->
		    green != 0xe3
		    || lyr->vector_style->polygon_sym->fill->graphic->color->
		    blue != 0x46)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerFillGraphicRemapColor #%02x%02x%02x !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->fill->graphic->
			       color->red,
			       lyr->vector_style->polygon_sym->fill->graphic->
			       color->green,
			       lyr->vector_style->polygon_sym->fill->graphic->
			       color->blue);
		      ret = -97;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->stroke == NULL)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL PolygonSymbolizerStroke !!\n",
................................................................................
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->stroke->dot_style != 2)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerStrokeDotStyle %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->
			       stroke->dot_style);
		      ret = -102;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->displacement_x != 5.3)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerDisplacementX %1.2f !!\n",
................................................................................
		  }
		if (lyr->vector_style->polygon_sym->perpendicular_offset !=
		    10.25)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerPerpendicularOffset %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->
			       perpendicular_offset);
		      ret = -104;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "vector_6") == 0)
	    {
................................................................................
		  }
		if (lyr->vector_style->text_sym->placement->point->rotation !=
		    45.2)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementRotation %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       point->rotation);
		      ret = -117;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->point->anchor_x !=
		    0.3)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementAnchorX %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       point->anchor_x);
		      ret = -118;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->point->anchor_y !=
		    2.5)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementAnchorY %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       point->anchor_y);
		      ret = -119;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->
		    point->displacement_x != 10.1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementDisplacementX %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       point->displacement_x);
		      ret = -120;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->
		    point->displacement_y != 0.32)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementDisplacementY %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       point->displacement_y);
		      ret = -121;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->halo == NULL)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL TextSymbolizerHalo !!\n",
................................................................................
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->halo->fill->opacity != 0.33)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerHaloFillOpacity %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->halo->
			       fill->opacity);
		      ret = -126;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->fill == NULL)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL TextSymbolizerFill !!\n",
................................................................................
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL TextSymbolizerLinePlacement !!\n",
			       lyr->prefix, lyr->name);
		      ret = -133;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->
		    perpendicular_offset != 1.32)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementPerpendicularOffset %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->line->
			       perpendicular_offset);
		      ret = -134;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->repeated != 1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementIsRepeated %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->line->
			       repeated);
		      ret = -135;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->initial_gap !=
		    5.25)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementInitialGap %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->line->
			       initial_gap);
		      ret = -136;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->gap != 10.5)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementGap %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->line->
			       gap);
		      ret = -137;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->aligned != 1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementIsAligned %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->line->
			       aligned);
		      ret = -138;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->generalize !=
		    1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementGeneralizeLine %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->line->
			       generalize);
		      ret = -139;
		      goto stop;
		  }
	    }
	  lyr = lyr->next;
      }

................................................................................
  error:
    if (xml != NULL)
	free (xml);
    if (in != NULL)
	fclose (in);
    return NULL;
}



















































































































































































































int
main (int argc, char *argv[])
{
    int result = 0;
    int ret;
    sqlite3 *db_handle;
................................................................................
    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

/* opening and initializing the "memory" test DB */
    ret = sqlite3_open_v2 (":memory:", &db_handle, SQLITE_OPEN_READONLY, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "sqlite3_open_v2() error: %s\n",
		   sqlite3_errmsg (db_handle));
	  return -1;
      }
    spatialite_init_ex (db_handle, cache, 0);
    rl2_init (db_handle, priv_data, 0);

/* loading the XML document */
................................................................................
/* closing the DB */
    sqlite3_close (db_handle);
    spatialite_cleanup_ex (cache);
    rl2_cleanup_private (priv_data);
    spatialite_shutdown ();
    if (xml != NULL)
	free (xml);



    return result;
}







|
|







 







|
|







 







|
|







 







|
|







 







|
|







 







|
|
|
|







 







|
|








|
|








|
|







 







|
|










|
|







 







|
|
|
|




|
|
|
|
|
|







 







|
|







 







|
|







 







|
|









|
|









|
|



|
|




|
|



|
|




|
|







 







|
|







 







|
|




|
|








|
|









|
|








|
|








|
|









|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







>
>
>


270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
...
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
...
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
...
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
...
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
...
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
....
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
....
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
....
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
....
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
....
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
....
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
....
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
....
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
....
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
....
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
		  }
		if (lyr->raster_style->contrast_enhancement->gamma_value !=
		    1.57)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected ContrastEnhancement GammaValue %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->raster_style->contrast_enhancement->
			       gamma_value);
		      ret = -19;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "raster_8") == 0)
	    {
................................................................................
		if (lyr->raster_style->channel_selection->rgb == 0
		    || lyr->raster_style->channel_selection->green_channel != 1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected ChannelSelection RGB=%d Green=%d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->raster_style->channel_selection->rgb,
			       lyr->raster_style->channel_selection->
			       green_channel);
		      ret = -23;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "raster_9") == 0)
	    {
................................................................................
		if (lyr->raster_style->channel_selection->rgb != 0
		    || lyr->raster_style->channel_selection->gray_channel != 4)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected ChannelSelection RGB=%d Green=%d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->raster_style->channel_selection->rgb,
			       lyr->raster_style->channel_selection->
			       gray_channel);
		      ret = -27;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "wms_layer_2") == 0)
	    {
................................................................................
		if (strcmp
		    (lyr->topology_internal_style->style_internal_name,
		     "topology_style_1") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected Internal Style Name \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->topology_internal_style->
			       style_internal_name);
		      ret = -57;
		      goto stop;
		  }
		if (lyr->topology_internal_style->show_faces == 0
		    || lyr->topology_internal_style->show_edges == 0
		    || lyr->topology_internal_style->show_nodes == 0
		    || lyr->topology_internal_style->show_edge_seeds == 0
................................................................................
		if (strcmp
		    (lyr->network_internal_style->style_internal_name,
		     "network_style_1") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected Internal Style Name \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->network_internal_style->
			       style_internal_name);
		      ret = -62;
		      goto stop;
		  }
		if (lyr->network_internal_style->show_links == 0 ||
		    lyr->network_internal_style->show_nodes == 0
		    || lyr->network_internal_style->show_link_seeds == 0)
		  {
................................................................................
		    lyr->vector_style->point_sym->mark->stroke->green != 0x03 ||
		    lyr->vector_style->point_sym->mark->stroke->blue != 0xfa)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PointSymbolizerMarkStroke #%02x%02x%02x !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->point_sym->mark->stroke->red,
			       lyr->vector_style->point_sym->mark->stroke->
			       green,
			       lyr->vector_style->point_sym->mark->stroke->
			       blue);
		      ret = -71;
		      goto stop;
		  }
		if (lyr->vector_style->point_sym->opacity != 0.75)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PointSymbolizerOpacity %1.2f !!\n",
................................................................................
		      goto stop;
		  }
		if (lyr->vector_style->first_line_sym->stroke->opacity != 0.66)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected LineSymbolizerStrokeOpacity %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->first_line_sym->stroke->
			       opacity);
		      ret = -82;
		      goto stop;
		  }
		if (lyr->vector_style->first_line_sym->stroke->width != 8.52)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected LineSymbolizerStrokeWidth %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->first_line_sym->stroke->
			       width);
		      ret = -83;
		      goto stop;
		  }
		if (lyr->vector_style->first_line_sym->stroke->dot_style != 4)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected LineSymbolizerStrokeDotStyle %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->first_line_sym->stroke->
			       dot_style);
		      ret = -84;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "topology_2") == 0)
	    {
................................................................................
		if (strcmp
		    (lyr->vector_style->polygon_sym->fill->graphic->resource,
		     "http://www.utopia.gov/stdbrush_crossdiag.png") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerFillGraphicResource \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->fill->
			       graphic->resource);
		      ret = -94;
		      goto stop;
		  }
		if (strcmp
		    (lyr->vector_style->polygon_sym->fill->graphic->format,
		     "image/png") != 0)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerFillGraphicFormat \"%s\" !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->fill->
			       graphic->format);
		      ret = -95;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->fill->graphic->color ==
		    NULL)
		  {
		      fprintf (stderr,
................................................................................
			       "Layer <%s><%s> unexpected NULL PolygonSymbolizerFillGraphicRemapColor !!\n",
			       lyr->prefix, lyr->name);
		      ret = -96;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->fill->graphic->color->red !=
		    0xfb
		    || lyr->vector_style->polygon_sym->fill->graphic->
		    color->green != 0xe3
		    || lyr->vector_style->polygon_sym->fill->graphic->
		    color->blue != 0x46)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerFillGraphicRemapColor #%02x%02x%02x !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->fill->
			       graphic->color->red,
			       lyr->vector_style->polygon_sym->fill->
			       graphic->color->green,
			       lyr->vector_style->polygon_sym->fill->
			       graphic->color->blue);
		      ret = -97;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->stroke == NULL)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL PolygonSymbolizerStroke !!\n",
................................................................................
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->stroke->dot_style != 2)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerStrokeDotStyle %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->polygon_sym->stroke->
			       dot_style);
		      ret = -102;
		      goto stop;
		  }
		if (lyr->vector_style->polygon_sym->displacement_x != 5.3)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerDisplacementX %1.2f !!\n",
................................................................................
		  }
		if (lyr->vector_style->polygon_sym->perpendicular_offset !=
		    10.25)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected PolygonSymbolizerPerpendicularOffset %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->
			       polygon_sym->perpendicular_offset);
		      ret = -104;
		      goto stop;
		  }
	    }
	  if (strcmp (lyr->prefix, "main") == 0
	      && strcmp (lyr->name, "vector_6") == 0)
	    {
................................................................................
		  }
		if (lyr->vector_style->text_sym->placement->point->rotation !=
		    45.2)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementRotation %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->point->
			       rotation);
		      ret = -117;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->point->anchor_x !=
		    0.3)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementAnchorX %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->point->
			       anchor_x);
		      ret = -118;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->point->anchor_y !=
		    2.5)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementAnchorY %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->point->
			       anchor_y);
		      ret = -119;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->point->
		    displacement_x != 10.1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementDisplacementX %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->point->
			       displacement_x);
		      ret = -120;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->point->
		    displacement_y != 0.32)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerPointPlacementDisplacementY %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->point->
			       displacement_y);
		      ret = -121;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->halo == NULL)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL TextSymbolizerHalo !!\n",
................................................................................
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->halo->fill->opacity != 0.33)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerHaloFillOpacity %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->halo->fill->
			       opacity);
		      ret = -126;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->fill == NULL)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL TextSymbolizerFill !!\n",
................................................................................
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected NULL TextSymbolizerLinePlacement !!\n",
			       lyr->prefix, lyr->name);
		      ret = -133;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->
		    line->perpendicular_offset != 1.32)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementPerpendicularOffset %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       line->perpendicular_offset);
		      ret = -134;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->repeated != 1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementIsRepeated %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       line->repeated);
		      ret = -135;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->initial_gap !=
		    5.25)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementInitialGap %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       line->initial_gap);
		      ret = -136;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->gap != 10.5)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementGap %1.2f !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       line->gap);
		      ret = -137;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->aligned != 1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementIsAligned %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       line->aligned);
		      ret = -138;
		      goto stop;
		  }
		if (lyr->vector_style->text_sym->placement->line->generalize !=
		    1)
		  {
		      fprintf (stderr,
			       "Layer <%s><%s> unexpected TextSymbolizerLinePlacementGeneralizeLine %d !!\n",
			       lyr->prefix, lyr->name,
			       lyr->vector_style->text_sym->placement->
			       line->generalize);
		      ret = -139;
		      goto stop;
		  }
	    }
	  lyr = lyr->next;
      }

................................................................................
  error:
    if (xml != NULL)
	free (xml);
    if (in != NULL)
	fclose (in);
    return NULL;
}

static int
test_rendering (sqlite3 * sqlite, const char *name, const char *mbr)
{
/* testing RL2_GetImageFromMapConfiguration() */
    char *sql;
    sqlite3_stmt *stmt;
    int ret;
    int ok = 0;

    sql = sqlite3_mprintf ("SELECT RL2_GetImageFromMapConfiguration(%Q, %s, "
			   "1024, 1024, 'image/jpeg', 85)", name, mbr);
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    sqlite3_free (sql);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "ERROR: invalid SQL !!!\n");
	  return -1;
      }
    while (1)
      {
	  /* scrolling the result set rows */
	  ret = sqlite3_step (stmt);
	  if (ret == SQLITE_DONE)
	      break;		/* end of result set */
	  if (ret == SQLITE_ROW)
	    {
		if (sqlite3_column_type (stmt, 0) == SQLITE_BLOB)
		    ok = 1;
		else
		    fprintf (stderr, "'%s': returned value is not a BLOB !!!\n",
			     name);
	    }
      }
    sqlite3_finalize (stmt);
    if (ok)
	return 0;
    else
      {
	  fprintf (stderr, "ERROR on RL2_GetImageFromMapConfiguration() '%s'\n",
		   name);
	  return -1;
      }
}

static int
do_test_rendering ()
{
    int result = 0;
    int ret;
    sqlite3 *db_handle;
    void *cache = spatialite_alloc_connection ();
    void *priv_data = rl2_alloc_private ();
    const char *db_path = "./map_config.sqlite";

/* opening and initializing the test DB */
    ret = sqlite3_open_v2 (db_path, &db_handle, SQLITE_OPEN_READONLY, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "sqlite3_open_v2() #2 error: %s\n",
		   sqlite3_errmsg (db_handle));
	  return -1;
      }
    spatialite_init_ex (db_handle, cache, 0);
    rl2_init (db_handle, priv_data, 0);

    ret =
	test_rendering (db_handle, "test",
			"BuildMbr(661080.36416380, 4847546.75435066, 661185.84211366, 4847652.23230052, 32632)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_nir",
			"BuildMbr(661080.36416380, 4847546.75435066, 661185.84211366, 4847652.23230052, 32632)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_ndvi",
			"BuildMbr(661080.36416380, 4847546.75435066, 661185.84211366, 4847652.23230052, 32632)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_ndwi",
			"BuildMbr(661080.36416380, 4847546.75435066, 661185.84211366, 4847652.23230052, 32632)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_topo",
			"BuildMbr(661080.36416380, 4847546.75435066, 661185.84211366, 4847652.23230052, 32632)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_network",
			"BuildMbr(661080.36416380, 4847546.75435066, 661185.84211366, 4847652.23230052, 32632)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_etopo2",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_srtm",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_terrain",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_aspect",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_elevation",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_rainbow",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_wave",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_sepia",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

    ret =
	test_rendering (db_handle, "test_ramp",
			"BuildMbr(1645836.00863381, 4739566.56487609, 1646963.24970982, 4740693.80595209, 3003)");
    if (ret < 0)
      {
	  result = ret;
	  goto stop;
      }

/* closing the DB */
  stop:
    sqlite3_close (db_handle);
    spatialite_cleanup_ex (cache);
    rl2_cleanup_private (priv_data);
    spatialite_shutdown ();

    return result;
}

int
main (int argc, char *argv[])
{
    int result = 0;
    int ret;
    sqlite3 *db_handle;
................................................................................
    if (argc > 1 || argv[0] == NULL)
	argc = 1;		/* silencing stupid compiler warnings */

/* opening and initializing the "memory" test DB */
    ret = sqlite3_open_v2 (":memory:", &db_handle, SQLITE_OPEN_READONLY, NULL);
    if (ret != SQLITE_OK)
      {
	  fprintf (stderr, "sqlite3_open_v2() #1 error: %s\n",
		   sqlite3_errmsg (db_handle));
	  return -1;
      }
    spatialite_init_ex (db_handle, cache, 0);
    rl2_init (db_handle, priv_data, 0);

/* loading the XML document */
................................................................................
/* closing the DB */
    sqlite3_close (db_handle);
    spatialite_cleanup_ex (cache);
    rl2_cleanup_private (priv_data);
    spatialite_shutdown ();
    if (xml != NULL)
	free (xml);

/* testing RL2_GetImageFromMapConfiguration() */
    result = do_test_rendering ();
    return result;
}

Changes to test/test_map_infrared.c.

1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
....
1323
1324
1325
1326
1327
1328
1329








1330

1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
....
1376
1377
1378
1379
1380
1381
1382



1383






1384

1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
....
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
....
2380
2381
2382
2383
2384
2385
2386



























2387
2388
2389
2390
2391
2392
2393
....
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
    sqlite3_free (path);
    if (strcmp(suffix, "png") == 0 && strcmp(style, "default") != 0)
		retcode = do_export_styled_map_image (sqlite, coverage, geom, style, suffix);
    return retcode;
}

static int
do_export_ndvi (sqlite3 * sqlite, const char *coverage, gaiaGeomCollPtr geom)
{
/* exporting an NDVI Ascii Grid */
    char *sql;
    const char *path = "./ndvi_ascii_grid.asc";
    sqlite3_stmt *stmt;
    int ret;
    double x_res;
    double y_res;
    double xx_res;
    double yy_res;
    unsigned char *blob;
................................................................................
    if (!get_base_resolution (sqlite, coverage, &x_res, &y_res))
	return 0;
    xx_res = x_res * (double) scale;
    yy_res = y_res * (double) scale;
    if (xx_res != yy_res)
	xx_res = (xx_res + yy_res) / 2.0;









    sql = "SELECT RL2_WriteNdviAsciiGrid('main', ?, ?, ?, ?, ?, ?, ?, ?)";

    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	return 0;
    sqlite3_reset (stmt);
    sqlite3_clear_bindings (stmt);
    sqlite3_bind_text (stmt, 1, coverage, strlen (coverage), SQLITE_STATIC);
    sqlite3_bind_text (stmt, 2, path, strlen (path), SQLITE_STATIC);
    sqlite3_bind_int (stmt, 3, 1024);
    sqlite3_bind_int (stmt, 4, 1024);
    sqlite3_bind_int (stmt, 5, 0);	/* red band */
    sqlite3_bind_int (stmt, 6, 3);	/* NIR band */
    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
    sqlite3_bind_blob (stmt, 7, blob, blob_size, free);
    sqlite3_bind_double (stmt, 8, xx_res);
    ret = sqlite3_step (stmt);
    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
      {
	  if (sqlite3_column_int (stmt, 0) == 1)
	      retcode = 1;
      }
    sqlite3_finalize (stmt);
    unlink (path);
    if (!retcode)
	fprintf (stderr, "ERROR: unable to export \"%s\"\n", path);
    return retcode;
}

static int
do_export_section_ndvi (sqlite3 * sqlite, const char *coverage,
			gaiaGeomCollPtr geom)
{
/* exporting a Section NDVI Ascii Grid */
    char *sql;
    const char *path = "./ndvi_ascii_grid_section.asc";
    sqlite3_stmt *stmt;
    int ret;
    double x_res;
    double y_res;
    double xx_res;
    double yy_res;
    unsigned char *blob;
................................................................................
    if (!get_base_resolution (sqlite, coverage, &x_res, &y_res))
	return 0;
    xx_res = x_res * (double) scale;
    yy_res = y_res * (double) scale;
    if (xx_res != yy_res)
	xx_res = (xx_res + yy_res) / 2.0;




    sql =






	"SELECT RL2_WriteSectionNdviAsciiGrid('main', ?, ?, ?, ?, ?, ?, ?, ?, ?)";

    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	return 0;
    sqlite3_reset (stmt);
    sqlite3_clear_bindings (stmt);
    sqlite3_bind_text (stmt, 1, coverage, strlen (coverage), SQLITE_STATIC);
    sqlite3_bind_int64 (stmt, 2, 1);
    sqlite3_bind_text (stmt, 3, path, strlen (path), SQLITE_STATIC);
    sqlite3_bind_int (stmt, 4, 1024);
    sqlite3_bind_int (stmt, 5, 1024);
    sqlite3_bind_int (stmt, 6, 0);	/* red band */
    sqlite3_bind_int (stmt, 7, 3);	/* NIR band */
    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
    sqlite3_bind_blob (stmt, 8, blob, blob_size, free);
    sqlite3_bind_double (stmt, 9, xx_res);
    ret = sqlite3_step (stmt);
    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
      {
	  if (sqlite3_column_int (stmt, 0) == 1)
	      retcode = 1;
      }
    sqlite3_finalize (stmt);
    unlink (path);
    if (!retcode)
	fprintf (stderr, "ERROR: unable to export \"%s\"\n", path);
    return retcode;
}

static gaiaGeomCollPtr
get_center_point (sqlite3 * sqlite, const char *coverage)
{
/* attempting to retrieve the Coverage's Center Point */
................................................................................
	  *retcode += -40;
	  return 0;
      }
    if (!do_export_mono_band_tiff_tfw (sqlite, coverage, geom, 1, 2))
      {
	  *retcode += -41;
	  return 0;
      }
    if (ndvi)
      {
	  /* NDVI Ascii Grid */
	  if (!do_export_ndvi (sqlite, coverage, geom))
	    {
		*retcode += -101;
		return 0;
	    }
      }
    if (!test_map_image)
	goto skip;

/* loading the RasterSymbolizers */
    sql =
	sqlite3_mprintf ("SELECT SE_RegisterRasterStyledLayer(%Q, 1)",
................................................................................

/* testing GetMapImage - NDVI */
    if (!test_default_bands (sqlite, coverage))
      {
	  *retcode += -102;
	  return 0;
      }



























    if (!do_export_map_image (sqlite, coverage, geom, "ndvi", "jpg", 0))
      {
	  *retcode += 104;
	  return 0;
      }

/* testing GetMapImage - IR false color */
................................................................................
		*retcode += -99;
		return 0;
	    }
	  if (!do_export_section_mono_tiff_tfw (sqlite, coverage, geom, 8))
	    {
		*retcode += -100;
		return 0;
	    }
	  if (ndvi)
	    {
		/* Section NDVI Ascii Grid */
		if (!do_export_section_ndvi (sqlite, coverage, geom))
		  {
		      *retcode += -102;
		      return 0;
		  }
	    }
	  gaiaFreeGeomColl (geom);
      }

    if (!do_test_tile_data (sqlite, compression, tile_sz))
      {
	  *retcode += -103;







|


|
|







 







>
>
>
>
>
>
>
>
|
>









<
<

|
|









|





|


|
|







 







>
>
>

>
>
>
>
>
>
|
>










<
<

|
|









|







 







<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<
<
<
<
<
<







1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
....
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348


1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
....
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411


1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
....
2309
2310
2311
2312
2313
2314
2315









2316
2317
2318
2319
2320
2321
2322
....
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
....
2711
2712
2713
2714
2715
2716
2717









2718
2719
2720
2721
2722
2723
2724
    sqlite3_free (path);
    if (strcmp(suffix, "png") == 0 && strcmp(style, "default") != 0)
		retcode = do_export_styled_map_image (sqlite, coverage, geom, style, suffix);
    return retcode;
}

static int
do_export_ndvi (sqlite3 * sqlite, const char *coverage, gaiaGeomCollPtr geom, int ndwi_mode)
{
/* exporting an NDVI Ascii Grid */
    const char *sql;
    const char *path;
    sqlite3_stmt *stmt;
    int ret;
    double x_res;
    double y_res;
    double xx_res;
    double yy_res;
    unsigned char *blob;
................................................................................
    if (!get_base_resolution (sqlite, coverage, &x_res, &y_res))
	return 0;
    xx_res = x_res * (double) scale;
    yy_res = y_res * (double) scale;
    if (xx_res != yy_res)
	xx_res = (xx_res + yy_res) / 2.0;

if (ndwi_mode)
{
    path = "./ndwi_ascii_grid.asc";
    sql = "SELECT RL2_WriteNdwiAsciiGrid('main', ?, ?, ?, ?, ?, ?)";
}
else
{
    path = "./ndvi_ascii_grid.asc";
    sql = "SELECT RL2_WriteNdviAsciiGrid('main', ?, ?, ?, ?, ?, ?)";
}
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	return 0;
    sqlite3_reset (stmt);
    sqlite3_clear_bindings (stmt);
    sqlite3_bind_text (stmt, 1, coverage, strlen (coverage), SQLITE_STATIC);
    sqlite3_bind_text (stmt, 2, path, strlen (path), SQLITE_STATIC);
    sqlite3_bind_int (stmt, 3, 1024);
    sqlite3_bind_int (stmt, 4, 1024);


    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
    sqlite3_bind_blob (stmt, 5, blob, blob_size, free);
    sqlite3_bind_double (stmt, 6, xx_res);
    ret = sqlite3_step (stmt);
    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
      {
	  if (sqlite3_column_int (stmt, 0) == 1)
	      retcode = 1;
      }
    sqlite3_finalize (stmt);
    unlink (path);
    if (!retcode)
	fprintf (stderr, "cov ERROR: unable to export \"%s\"\n", path);
    return retcode;
}

static int
do_export_section_ndvi (sqlite3 * sqlite, const char *coverage,
			gaiaGeomCollPtr geom, int ndwi_mode)
{
/* exporting a Section NDVI Ascii Grid */
    const char *sql;
    const char *path;
    sqlite3_stmt *stmt;
    int ret;
    double x_res;
    double y_res;
    double xx_res;
    double yy_res;
    unsigned char *blob;
................................................................................
    if (!get_base_resolution (sqlite, coverage, &x_res, &y_res))
	return 0;
    xx_res = x_res * (double) scale;
    yy_res = y_res * (double) scale;
    if (xx_res != yy_res)
	xx_res = (xx_res + yy_res) / 2.0;

if (ndwi_mode)
{
    path = "./ndwi_ascii_grid_section.asc";
    sql =
	"SELECT RL2_WriteSectionNdwiAsciiGrid('main', ?, ?, ?, ?, ?, ?, ?)";
}
else
{
    path = "./ndvi_ascii_grid_section.asc";
    sql =
	"SELECT RL2_WriteSectionNdviAsciiGrid('main', ?, ?, ?, ?, ?, ?, ?)";
}
    ret = sqlite3_prepare_v2 (sqlite, sql, strlen (sql), &stmt, NULL);
    if (ret != SQLITE_OK)
	return 0;
    sqlite3_reset (stmt);
    sqlite3_clear_bindings (stmt);
    sqlite3_bind_text (stmt, 1, coverage, strlen (coverage), SQLITE_STATIC);
    sqlite3_bind_int64 (stmt, 2, 1);
    sqlite3_bind_text (stmt, 3, path, strlen (path), SQLITE_STATIC);
    sqlite3_bind_int (stmt, 4, 1024);
    sqlite3_bind_int (stmt, 5, 1024);


    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
    sqlite3_bind_blob (stmt, 6, blob, blob_size, free);
    sqlite3_bind_double (stmt, 7, xx_res);
    ret = sqlite3_step (stmt);
    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
      {
	  if (sqlite3_column_int (stmt, 0) == 1)
	      retcode = 1;
      }
    sqlite3_finalize (stmt);
    unlink (path);
    if (!retcode)
	fprintf (stderr, "sect ERROR: unable to export \"%s\"\n", path);
    return retcode;
}

static gaiaGeomCollPtr
get_center_point (sqlite3 * sqlite, const char *coverage)
{
/* attempting to retrieve the Coverage's Center Point */
................................................................................
	  *retcode += -40;
	  return 0;
      }
    if (!do_export_mono_band_tiff_tfw (sqlite, coverage, geom, 1, 2))
      {
	  *retcode += -41;
	  return 0;









      }
    if (!test_map_image)
	goto skip;

/* loading the RasterSymbolizers */
    sql =
	sqlite3_mprintf ("SELECT SE_RegisterRasterStyledLayer(%Q, 1)",
................................................................................

/* testing GetMapImage - NDVI */
    if (!test_default_bands (sqlite, coverage))
      {
	  *retcode += -102;
	  return 0;
      }
    if (ndvi)
      {
	  /* NDVI Ascii Grid */
	  if (!do_export_ndvi (sqlite, coverage, geom, 0))
	    {
		*retcode += -101;
		return 0;
	    }
		/* Section NDVI Ascii Grid */
		if (!do_export_section_ndvi (sqlite, coverage, geom, 0))
		  {
		      *retcode += -102;
		      return 0;
		  }
	  /* NDWI Ascii Grid */
	  if (!do_export_ndvi (sqlite, coverage, geom, 1))
	    {
		*retcode += -101;
		return 0;
	    }
		/* Section NDWI Ascii Grid */
		if (!do_export_section_ndvi (sqlite, coverage, geom, 1))
		  {
		      *retcode += -102;
		      return 0;
		  }
	    }
    if (!do_export_map_image (sqlite, coverage, geom, "ndvi", "jpg", 0))
      {
	  *retcode += 104;
	  return 0;
      }

/* testing GetMapImage - IR false color */
................................................................................
		*retcode += -99;
		return 0;
	    }
	  if (!do_export_section_mono_tiff_tfw (sqlite, coverage, geom, 8))
	    {
		*retcode += -100;
		return 0;









	    }
	  gaiaFreeGeomColl (geom);
      }

    if (!do_test_tile_data (sqlite, compression, tile_sz))
      {
	  *retcode += -103;

Changes to test/test_map_vector.c.

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
    int retcode = 1;
    char *path;
    int i;
    unsigned char *rgb;
    unsigned char *alpha;
    unsigned char *png = NULL;
    int png_size;
    int has_labels;
    FILE *out;
    int half_transparent;
    rl2GraphicsContextPtr ctx = NULL;
    rl2GraphicsContextPtr ctx_labels = NULL;
    rl2GraphicsContextPtr ctx_nodes = NULL;
    rl2GraphicsContextPtr ctx_edges = NULL;
    rl2GraphicsContextPtr ctx_links = NULL;
    rl2GraphicsContextPtr ctx_faces = NULL;
    rl2GraphicsContextPtr ctx_edge_seeds = NULL;
    rl2GraphicsContextPtr ctx_link_seeds = NULL;
    rl2GraphicsContextPtr ctx_face_seeds = NULL;
................................................................................
    rl2CanvasPtr canvas = NULL;

    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_sz);

    if (toponet)
      {
	  ctx = rl2_graph_create_context (data, 1024, 1024);
	  ctx_labels = rl2_graph_create_context (data, 1024, 1024);
	  ctx_nodes = rl2_graph_create_context (data, 1024, 1024);
	  ctx_links = rl2_graph_create_context (data, 1024, 1024);
	  ctx_link_seeds = rl2_graph_create_context (data, 1024, 1024);
	  canvas =
	      rl2_create_network_canvas (ctx, ctx_labels, ctx_nodes, ctx_links,
					 ctx_link_seeds);
      }
    if (topogeo)
      {
	  ctx = rl2_graph_create_context (data, 1024, 1024);
	  ctx_labels = rl2_graph_create_context (data, 1024, 1024);
	  ctx_nodes = rl2_graph_create_context (data, 1024, 1024);
	  ctx_edges = rl2_graph_create_context (data, 1024, 1024);
	  ctx_faces = rl2_graph_create_context (data, 1024, 1024);
	  ctx_edge_seeds = rl2_graph_create_context (data, 1024, 1024);
	  ctx_face_seeds = rl2_graph_create_context (data, 1024, 1024);
	  canvas =
	      rl2_create_topology_canvas (ctx, ctx_labels, ctx_nodes, ctx_edges,
					  ctx_faces, ctx_edge_seeds,
					  ctx_face_seeds);
      }

    switch (mode)
      {
      case 0:
	  ret =
	      rl2_map_image_paint_from_vector (sqlite, data, canvas, NULL,
					       coverage, blob, blob_sz, 0,
					       style, NULL, &has_labels);
	  break;
      case 1:
	  ret =
	      rl2_map_image_paint_from_vector_ex (sqlite, data, canvas, NULL,
						  coverage, blob, blob_sz, 0,
						  style, NULL, 1, 1, 1, 1, 1, &has_labels);
	  break;
      case 2:
	  ret =
	      rl2_map_image_paint_from_vector_ex (sqlite, data, canvas, NULL,
						  coverage, blob, blob_sz, 0,
						  style, NULL, 0, 1, 0, 1, 0, &has_labels);
	  break;
      case 3:
	  ret =
	      rl2_map_image_paint_from_vector_ex (sqlite, data, canvas, NULL,
						  coverage, blob, blob_sz, 0,
						  style, NULL, 1, 0, 1, 0, 1, &has_labels);
	  break;
      };
    if (ret != RL2_OK)
      {
	  fprintf (stderr, "C API (base) failure !!! (%s - %s)\n", coverage,
		   (style == NULL) ? "NULL" : style);
	  return 0;







<



<







 







<




|





<






|










|





|





|





|







277
278
279
280
281
282
283

284
285
286

287
288
289
290
291
292
293
...
294
295
296
297
298
299
300

301
302
303
304
305
306
307
308
309
310

311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
    int retcode = 1;
    char *path;
    int i;
    unsigned char *rgb;
    unsigned char *alpha;
    unsigned char *png = NULL;
    int png_size;

    FILE *out;
    int half_transparent;
    rl2GraphicsContextPtr ctx = NULL;

    rl2GraphicsContextPtr ctx_nodes = NULL;
    rl2GraphicsContextPtr ctx_edges = NULL;
    rl2GraphicsContextPtr ctx_links = NULL;
    rl2GraphicsContextPtr ctx_faces = NULL;
    rl2GraphicsContextPtr ctx_edge_seeds = NULL;
    rl2GraphicsContextPtr ctx_link_seeds = NULL;
    rl2GraphicsContextPtr ctx_face_seeds = NULL;
................................................................................
    rl2CanvasPtr canvas = NULL;

    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_sz);

    if (toponet)
      {
	  ctx = rl2_graph_create_context (data, 1024, 1024);

	  ctx_nodes = rl2_graph_create_context (data, 1024, 1024);
	  ctx_links = rl2_graph_create_context (data, 1024, 1024);
	  ctx_link_seeds = rl2_graph_create_context (data, 1024, 1024);
	  canvas =
	      rl2_create_network_canvas (ctx, ctx_nodes, ctx_links,
					 ctx_link_seeds);
      }
    if (topogeo)
      {
	  ctx = rl2_graph_create_context (data, 1024, 1024);

	  ctx_nodes = rl2_graph_create_context (data, 1024, 1024);
	  ctx_edges = rl2_graph_create_context (data, 1024, 1024);
	  ctx_faces = rl2_graph_create_context (data, 1024, 1024);
	  ctx_edge_seeds = rl2_graph_create_context (data, 1024, 1024);
	  ctx_face_seeds = rl2_graph_create_context (data, 1024, 1024);
	  canvas =
	      rl2_create_topology_canvas (ctx, ctx_nodes, ctx_edges,
					  ctx_faces, ctx_edge_seeds,
					  ctx_face_seeds);
      }

    switch (mode)
      {
      case 0:
	  ret =
	      rl2_map_image_paint_from_vector (sqlite, data, canvas, NULL,
					       coverage, blob, blob_sz, 0,
					       style, NULL);
	  break;
      case 1:
	  ret =
	      rl2_map_image_paint_from_vector_ex (sqlite, data, canvas, NULL,
						  coverage, blob, blob_sz, 0,
						  style, NULL, 1, 1, 1, 1, 1);
	  break;
      case 2:
	  ret =
	      rl2_map_image_paint_from_vector_ex (sqlite, data, canvas, NULL,
						  coverage, blob, blob_sz, 0,
						  style, NULL, 0, 1, 0, 1, 0);
	  break;
      case 3:
	  ret =
	      rl2_map_image_paint_from_vector_ex (sqlite, data, canvas, NULL,
						  coverage, blob, blob_sz, 0,
						  style, NULL, 1, 0, 1, 0, 1);
	  break;
      };
    if (ret != RL2_OK)
      {
	  fprintf (stderr, "C API (base) failure !!! (%s - %s)\n", coverage,
		   (style == NULL) ? "NULL" : style);
	  return 0;