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;
212S57Obj::S57Obj(
const char *featureName) {
215 attVal =
new wxArrayOfS57attVal();
217 strncpy(FeatureName, featureName, 6);
220 if (!strncmp(FeatureName,
"DEPARE", 6) || !strncmp(FeatureName,
"DRGARE", 6))
221 bIsAssociable =
true;
224bool S57Obj::AddIntegerAttribute(
const char *acronym,
int val) {
225 S57attVal *pattValTmp =
new S57attVal;
227 int *pAVI = (
int *)malloc(
sizeof(
int));
230 pattValTmp->valType = OGR_INT;
231 pattValTmp->value = pAVI;
233 att_array = (
char *)realloc(att_array, 6 * (n_attr + 1));
234 strncpy(att_array + (6 *
sizeof(
char) * n_attr), acronym, 6);
237 attVal->Add(pattValTmp);
239 if (!strncmp(acronym,
"SCAMIN", 6)) Scamin = val;
244bool S57Obj::AddIntegerListAttribute(
const char *acronym,
int *pval,
249bool S57Obj::AddDoubleAttribute(
const char *acronym,
double val) {
250 S57attVal *pattValTmp =
new S57attVal;
252 double *pAVI = (
double *)malloc(
sizeof(
double));
255 pattValTmp->valType = OGR_REAL;
256 pattValTmp->value = pAVI;
258 att_array = (
char *)realloc(att_array, 6 * (n_attr + 1));
259 strncpy(att_array + (6 *
sizeof(
char) * n_attr), acronym, 6);
262 attVal->Add(pattValTmp);
267bool S57Obj::AddDoubleListAttribute(
const char *acronym,
double *pval,
272bool S57Obj::AddStringAttribute(
const char *acronym,
char *val) {
273 S57attVal *pattValTmp =
new S57attVal;
275 char *pAVS = (
char *)malloc(strlen(val) + 1);
278 pattValTmp->valType = OGR_STR;
279 pattValTmp->value = pAVS;
281 att_array = (
char *)realloc(att_array, 6 * (n_attr + 1));
282 strncpy(att_array + (6 *
sizeof(
char) * n_attr), acronym, 6);
285 attVal->Add(pattValTmp);
290bool S57Obj::SetPointGeometry(
double lat,
double lon,
double ref_lat,
292 Primitive_type = GEO_POINT;
298 double bound = 1. / 60.;
299 BBObj.Set(m_lat - bound, m_lon - bound, m_lat + bound, m_lon + bound);
300 bBBObj_valid =
false;
303 double easting, northing;
304 toSM(lat, lon, ref_lat, ref_lon, &easting, &northing);
314bool S57Obj::SetLineGeometry(LineGeometryDescriptor *pGeo, GeoPrim_t geoType,
315 double ref_lat,
double ref_lon) {
316 Primitive_type = geoType;
319 BBObj.Set(pGeo->extent_s_lat, pGeo->extent_w_lon, pGeo->extent_n_lat,
324 double e1, e2, n1, n2;
325 toSM(pGeo->extent_n_lat, pGeo->extent_e_lon, ref_lat, ref_lon, &e1, &n1);
326 toSM(pGeo->extent_s_lat, pGeo->extent_w_lon, ref_lat, ref_lon, &e2, &n2);
333 fromSM(x, y, ref_lat, ref_lon, &yll, &xll);
338 m_n_lsindex = pGeo->indexCount;
339 m_lsindex_array = pGeo->indexTable;
341 m_n_edge_max_points =
347bool S57Obj::SetAreaGeometry(PolyTessGeo *ppg,
double ref_lat,
double ref_lon) {
348 Primitive_type = GEO_AREA;
352 BBObj.Set(ppg->Get_ymin(), ppg->Get_xmin(), ppg->Get_ymax(), ppg->Get_xmax());
356 double e1, e2, n1, n2;
357 toSM(ppg->Get_ymax(), ppg->Get_xmax(), ref_lat, ref_lon, &e1, &n1);
358 toSM(ppg->Get_ymin(), ppg->Get_xmin(), ref_lat, ref_lon, &e2, &n2);
365 fromSM(x, y, ref_lat, ref_lon, &yll, &xll);
372bool S57Obj::SetMultipointGeometry(MultipointGeometryDescriptor *pGeo,
373 double ref_lat,
double ref_lon) {
374 Primitive_type = GEO_POINT;
376 npt = pGeo->pointCount;
378 geoPtz = (
double *)malloc(npt * 3 *
sizeof(
double));
379 geoPtMulti = (
double *)malloc(npt * 2 *
sizeof(
double));
381 double *pdd = geoPtz;
382 double *pdl = geoPtMulti;
384 float *pfs = (
float *)(pGeo->pointTable);
385 for (
int ip = 0; ip < npt; ip++) {
386 float easting, northing;
389 float depth = *pfs++;
397 fromSM(easting, northing, ref_lat, ref_lon, &yll, &xll);
404 BBObj.Set(pGeo->extent_s_lat, pGeo->extent_w_lon, pGeo->extent_n_lat,
411int S57Obj::GetAttributeIndex(
const char *AttrSeek) {
412 char *patl = att_array;
414 for (
int i = 0; i < n_attr; i++) {
415 if (!strncmp(patl, AttrSeek, 6)) {
426wxString S57Obj::GetAttrValueAsString(
const char *AttrName) {
429 int idx = GetAttributeIndex(AttrName);
434 S57attVal *v = attVal->Item(idx);
436 switch (v->valType) {
438 char *val = (
char *)(v->value);
439 str.Append(wxString(val, wxConvUTF8));
443 double dval = *(
double *)(v->value);
444 str.Printf(
"%g", dval);
448 int ival = *((
int *)v->value);
449 str.Printf(
"%d", ival);
453 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.