29#include "wx/tokenzr.h"
30#include <wx/textfile.h>
48#include "gdal/cpl_csv.h"
58#include <wx/msw/msvcrt.h>
69#define strncasecmp(x, y, z) _strnicmp(x, y, z)
73#include <wx/msw/msvcrt.h>
84#include <wx/textfile.h>
86#include <wx/tokenzr.h>
88#include "gdal/cpl_csv.h"
116S57Obj::S57Obj() { Init(); }
126 for (
unsigned int iv = 0; iv < attVal->GetCount(); iv++) {
127 S57attVal *vv = attVal->Item(iv);
128 void *v2 = vv->value;
138 bool b_useVBO = g_b_EnableVBO && !auxParm1;
140 PolyTriGroup *ppg_vbo = pPolyTessGeo->Get_PolyTriGroup_head();
141 if (b_useVBO && ppg_vbo && auxParm0 > 0 && ppg_vbo->single_buffer) {
142 glDeleteBuffers(1, (GLuint *)&auxParm0);
148 if (FText)
delete FText;
150 if (geoPt) free(geoPt);
151 if (geoPtz) free(geoPtz);
152 if (geoPtMulti) free(geoPtMulti);
154 if (m_lsindex_array) free(m_lsindex_array);
157 line_segment_element *element = m_ls_list;
159 line_segment_element *next = element->next;
187 bIsAssociable =
false;
189 m_lsindex_array = NULL;
190 m_n_edge_max_points = 0;
192 m_ls_list_legacy = 0;
195 bBBObj_valid =
false;
196 bOK_to_Render =
true;
213S57Obj::S57Obj(
const char *featureName) {
216 attVal =
new wxArrayOfS57attVal();
218 strncpy(FeatureName, featureName, 6);
221 if (!strncmp(FeatureName,
"DEPARE", 6) || !strncmp(FeatureName,
"DRGARE", 6))
222 bIsAssociable =
true;
225bool S57Obj::AddIntegerAttribute(
const char *acronym,
int val) {
226 S57attVal *pattValTmp =
new S57attVal;
228 int *pAVI = (
int *)malloc(
sizeof(
int));
231 pattValTmp->valType = OGR_INT;
232 pattValTmp->value = pAVI;
234 att_array = (
char *)realloc(att_array, 6 * (n_attr + 1));
235 strncpy(att_array + (6 *
sizeof(
char) * n_attr), acronym, 6);
238 attVal->Add(pattValTmp);
240 if (!strncmp(acronym,
"SCAMIN", 6)) Scamin = val;
245bool S57Obj::AddIntegerListAttribute(
const char *acronym,
int *pval,
250bool S57Obj::AddDoubleAttribute(
const char *acronym,
double val) {
251 S57attVal *pattValTmp =
new S57attVal;
253 double *pAVI = (
double *)malloc(
sizeof(
double));
256 pattValTmp->valType = OGR_REAL;
257 pattValTmp->value = pAVI;
259 att_array = (
char *)realloc(att_array, 6 * (n_attr + 1));
260 strncpy(att_array + (6 *
sizeof(
char) * n_attr), acronym, 6);
263 attVal->Add(pattValTmp);
268bool S57Obj::AddDoubleListAttribute(
const char *acronym,
double *pval,
273bool S57Obj::AddStringAttribute(
const char *acronym,
char *val) {
274 S57attVal *pattValTmp =
new S57attVal;
276 char *pAVS = (
char *)malloc(strlen(val) + 1);
279 pattValTmp->valType = OGR_STR;
280 pattValTmp->value = pAVS;
282 att_array = (
char *)realloc(att_array, 6 * (n_attr + 1));
283 strncpy(att_array + (6 *
sizeof(
char) * n_attr), acronym, 6);
286 attVal->Add(pattValTmp);
291bool S57Obj::SetPointGeometry(
double lat,
double lon,
double ref_lat,
293 Primitive_type = GEO_POINT;
299 double bound = 1. / 60.;
300 BBObj.Set(m_lat - bound, m_lon - bound, m_lat + bound, m_lon + bound);
301 bBBObj_valid =
false;
304 double easting, northing;
305 toSM(lat, lon, ref_lat, ref_lon, &easting, &northing);
315bool S57Obj::SetLineGeometry(LineGeometryDescriptor *pGeo, GeoPrim_t geoType,
316 double ref_lat,
double ref_lon) {
317 Primitive_type = geoType;
320 BBObj.Set(pGeo->extent_s_lat, pGeo->extent_w_lon, pGeo->extent_n_lat,
325 double e1, e2, n1, n2;
326 toSM(pGeo->extent_n_lat, pGeo->extent_e_lon, ref_lat, ref_lon, &e1, &n1);
327 toSM(pGeo->extent_s_lat, pGeo->extent_w_lon, ref_lat, ref_lon, &e2, &n2);
334 fromSM(x, y, ref_lat, ref_lon, &yll, &xll);
339 m_n_lsindex = pGeo->indexCount;
340 m_lsindex_array = pGeo->indexTable;
342 m_n_edge_max_points =
348bool S57Obj::SetAreaGeometry(PolyTessGeo *ppg,
double ref_lat,
double ref_lon) {
349 Primitive_type = GEO_AREA;
353 BBObj.Set(ppg->Get_ymin(), ppg->Get_xmin(), ppg->Get_ymax(), ppg->Get_xmax());
357 double e1, e2, n1, n2;
358 toSM(ppg->Get_ymax(), ppg->Get_xmax(), ref_lat, ref_lon, &e1, &n1);
359 toSM(ppg->Get_ymin(), ppg->Get_xmin(), ref_lat, ref_lon, &e2, &n2);
366 fromSM(x, y, ref_lat, ref_lon, &yll, &xll);
373bool S57Obj::SetMultipointGeometry(MultipointGeometryDescriptor *pGeo,
374 double ref_lat,
double ref_lon) {
375 Primitive_type = GEO_POINT;
377 npt = pGeo->pointCount;
379 geoPtz = (
double *)malloc(npt * 3 *
sizeof(
double));
380 geoPtMulti = (
double *)malloc(npt * 2 *
sizeof(
double));
382 double *pdd = geoPtz;
383 double *pdl = geoPtMulti;
385 float *pfs = (
float *)(pGeo->pointTable);
386 for (
int ip = 0; ip < npt; ip++) {
387 float easting, northing;
390 float depth = *pfs++;
398 fromSM(easting, northing, ref_lat, ref_lon, &yll, &xll);
405 BBObj.Set(pGeo->extent_s_lat, pGeo->extent_w_lon, pGeo->extent_n_lat,
412int S57Obj::GetAttributeIndex(
const char *AttrSeek) {
413 char *patl = att_array;
415 for (
int i = 0; i < n_attr; i++) {
416 if (!strncmp(patl, AttrSeek, 6)) {
427wxString S57Obj::GetAttrValueAsString(
const char *AttrName) {
430 int idx = GetAttributeIndex(AttrName);
435 S57attVal *v = attVal->Item(idx);
437 switch (v->valType) {
439 char *val = (
char *)(v->value);
440 str.Append(wxString(val, wxConvUTF8));
444 double dval = *(
double *)(v->value);
445 str.Printf(
"%g", dval);
449 int ival = *((
int *)v->value);
450 str.Printf(
"%d", ival);
454 str.Printf(
"Unknown attribute type");
Extern C linked utilities.
OpenGL chart rendering canvas.
Miscellaneous globals primarely used by gui layer, not persisted in configuration file.
Optimized wxBitmap Object.
Layer to use wxDC or opengl.
PlugInManager and helper classes – Mostly gui parts (dialogs) and plugin API stuff.