Skip to content

Commit 277605b

Browse files
committed
[pal] Remove #ifdef svg debugging code
1 parent 44724f9 commit 277605b

File tree

8 files changed

+75
-267
lines changed

8 files changed

+75
-267
lines changed

src/core/pal/feature.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,20 +1322,12 @@ namespace pal
13221322

13231323
int FeaturePart::setPosition( double scale, LabelPosition ***lPos,
13241324
double bbox_min[2], double bbox_max[2],
1325-
PointSet *mapShape, RTree<LabelPosition*, double, 2, double> *candidates
1326-
#ifdef _EXPORT_MAP_
1327-
, std::ofstream &svgmap
1328-
#endif
1329-
)
1325+
PointSet *mapShape, RTree<LabelPosition*, double, 2, double> *candidates )
13301326
{
13311327
int nbp = 0;
13321328
int i;
13331329
double bbox[4];
13341330

1335-
#ifdef _EXPORT_MAP_
1336-
int dpi = layer->pal->getDpi();
1337-
#endif
1338-
13391331
bbox[0] = bbox_min[0];
13401332
bbox[1] = bbox_min[1];
13411333
bbox[2] = bbox_max[0];

src/core/pal/feature.h

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,28 +127,28 @@ namespace pal
127127
//FeaturePart** parts;
128128
};
129129

130-
/**
130+
/**
131131
* \brief Main class to handle feature
132132
*/
133133
class CORE_EXPORT FeaturePart : public PointSet
134134
{
135135

136136
public:
137137

138-
/**
138+
/**
139139
* \brief create a new generic feature
140140
*
141141
* \param feat a pointer for a Feat which contains the spatial entites
142142
* \param geom a pointer to a GEOS geometry
143143
*/
144144
FeaturePart( Feature *feat, const GEOSGeometry* geom );
145145

146-
/**
146+
/**
147147
* \brief Delete the feature
148148
*/
149149
virtual ~FeaturePart();
150150

151-
/**
151+
/**
152152
* \brief generate candidates for point feature
153153
* Generate candidates for point features
154154
* \param x x coordinates of the point
@@ -161,12 +161,12 @@ namespace pal
161161
*/
162162
int setPositionForPoint( double x, double y, double scale, LabelPosition ***lPos, double delta_width, double angle );
163163

164-
/**
164+
/**
165165
* generate one candidate over specified point
166166
*/
167167
int setPositionOverPoint( double x, double y, double scale, LabelPosition ***lPos, double delta_width, double angle );
168168

169-
/**
169+
/**
170170
* \brief generate candidates for line feature
171171
* Generate candidates for line features
172172
* \param scale map scale is 1:scale
@@ -180,12 +180,12 @@ namespace pal
180180
LabelPosition* curvedPlacementAtOffset( PointSet* path_positions, double* path_distances,
181181
int orientation, int index, double distance );
182182

183-
/**
183+
/**
184184
* Generate curved candidates for line features
185185
*/
186186
int setPositionForLineCurved( LabelPosition ***lPos, PointSet* mapShape );
187187

188-
/**
188+
/**
189189
* \brief generate candidates for point feature
190190
* Generate candidates for point features
191191
* \param scale map scale is 1:scale
@@ -196,25 +196,25 @@ namespace pal
196196
*/
197197
int setPositionForPolygon( double scale, LabelPosition ***lPos, PointSet *mapShape, double delta_width );
198198

199-
/**
199+
/**
200200
* \brief return the feature
201201
* \return the feature
202202
*/
203203
Feature* getFeature() { return f; }
204204

205-
/**
205+
/**
206206
* \brief return the geometry
207207
* \return the geometry
208208
*/
209209
const GEOSGeometry* getGeometry() const { return the_geom; }
210210

211-
/**
211+
/**
212212
* \brief return the layer that feature belongs to
213213
* \return the layer of the feature
214214
*/
215215
Layer * getLayer();
216216

217-
/**
217+
/**
218218
* \brief generic method to generate candidates
219219
* This method will call either setPositionFromPoint(), setPositionFromLine or setPositionFromPolygon
220220
* \param scale the map scale is 1:scale
@@ -225,20 +225,16 @@ namespace pal
225225
* \param candidates index for candidates
226226
* \return the number of candidates in *lPos
227227
*/
228-
int setPosition( double scale, LabelPosition ***lPos, double bbox_min[2], double bbox_max[2], PointSet *mapShape, RTree<LabelPosition*, double, 2, double>*candidates
229-
#ifdef _EXPORT_MAP_
230-
, std::ofstream &svgmap
231-
#endif
232-
);
228+
int setPosition( double scale, LabelPosition ***lPos, double bbox_min[2], double bbox_max[2], PointSet *mapShape, RTree<LabelPosition*, double, 2, double>*candidates );
233229

234-
/**
230+
/**
235231
* \brief get the unique id of the feature
236232
* \return the feature unique identifier
237233
*/
238234
const char *getUID();
239235

240236

241-
/**
237+
/**
242238
* \brief Print feature information
243239
* Print feature unique id, geometry type, points, and holes on screen
244240
*/

src/core/pal/geomfunction.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -573,52 +573,6 @@ namespace pal
573573
return c;
574574
}
575575

576-
#ifdef _EXPORT_MAP_
577-
void toSVGPath( int nbPoints, int geomType, double *x, double *y,
578-
int dpi, double scale, int xmin, int ymax,
579-
char *layername, char *objectID,
580-
std::ostream &out )
581-
{
582-
int i;
583-
584-
if ( nbPoints > 1 )
585-
{
586-
out << " <path style=\"fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1\" d=\"M " << convert2pt( x[0], scale, dpi ) - xmin << "," << ymax - convert2pt( y[0], scale, dpi ) << " ";
587-
for ( i = 1; i < nbPoints; i++ )
588-
{
589-
out << "L " << convert2pt( x[i], scale, dpi ) - xmin << ", " << ymax - convert2pt( y[i], scale, dpi ) << " ";
590-
}
591-
592-
if ( geomType == GEOS_POLYGON )
593-
{
594-
out << " z ";
595-
}
596-
597-
out << "\" ";
598-
out << "id=\"" << layername << "-" << objectID << "\" ";
599-
out << "inkscape:label=\"#path-" << layername << "-" << objectID << "\"/>\n";
600-
}
601-
else
602-
{
603-
int cx = convert2pt( x[0], scale, dpi ) - xmin;
604-
int cy = ymax - convert2pt( y[0], scale, dpi );
605-
out << " <path ";
606-
out << " sodipodi:type=\"arc\" ";
607-
out << " style=\"opacity:1;fill:#bcbcbc;fill-opacity:l;stroke:#000000;stroke-opacity:1;stroke-width:0.5;stroke-linejoin:miter;stroke-dasharray:none;display:inline\"";
608-
out << " id=\"" << layername << "-" << objectID << "\" ";
609-
out << " sodipodi:cx=\"" << cx << "\" ";
610-
out << " sodipodi:cy=\"" << cy << "\" ";
611-
out << " sodipodi:rx=\"1\" ";
612-
out << " sodipodi:ry=\"1\" ";
613-
out << " d=\"M " << cx + 1 << " " << cy << " A 1 1 0 1 1 "
614-
<< cx - 1 << "," << cy << " A 1 1 0 1 1 "
615-
<< cx + 1 << " " << cy << " z\" ";
616-
out << " inkscape:label=\"#path-" << layername << "-" << objectID << "\" />\n";
617-
}
618-
}
619-
#endif
620-
621-
622576
void findLineCircleIntersection( double cx, double cy, double radius,
623577
double x1, double y1, double x2, double y2,
624578
double& xRes, double& yRes )

src/core/pal/geomfunction.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,31 +122,6 @@ namespace pal
122122
double x3, double y3, double x4, double y4, // 2nd line segment
123123
double *x, double *y );
124124

125-
#ifdef _EXPORT_MAP_
126-
/**
127-
* \brief generate SVG code for a geometry
128-
*
129-
* @param nbPoints # points in x and y vector
130-
* @param typeID from geos
131-
* @param x x coordinates
132-
* @param y y coordinates
133-
* @param dpi map resolution
134-
* @param scale map scale is 1:scale
135-
* @param xmin minimum x value in mapExtent
136-
* @param ymax maximum y value in mapExtent
137-
* @param layername SVG layer name
138-
* @param objectID SVG ID
139-
* @param out stream to write
140-
*/
141-
void toSVGPath( int nbPoints, int geomType,
142-
double *x, double *y,
143-
int dpi, double scale,
144-
int xmin, int ymax,
145-
char *layername,
146-
char *objectID,
147-
std::ostream &out );
148-
#endif
149-
150125
int reorderPolygon( int nbPoints, double *x, double *y );
151126

152127
} // end namespace

src/core/pal/pal.cpp

Lines changed: 4 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
*/
2929

3030
//#define _VERBOSE_
31-
//#define _EXPORT_MAP_
3231
#include <QTime>
3332

3433
#define _CRT_SECURE_NO_DEPRECATE
@@ -211,9 +210,6 @@ namespace pal
211210
double priority;
212211
double bbox_min[2];
213212
double bbox_max[2];
214-
#ifdef _EXPORT_MAP_
215-
std::ofstream *svgmap;
216-
#endif
217213
} FeatCallBackCtx;
218214

219215

@@ -229,12 +225,6 @@ namespace pal
229225

230226
FeatCallBackCtx *context = ( FeatCallBackCtx* ) ctx;
231227

232-
#ifdef _EXPORT_MAP_
233-
bool svged = false; // is the feature has been written into the svg map?
234-
int dpi = context->layer->pal->getDpi();
235-
#endif
236-
237-
238228
#ifdef _DEBUG_FULL_
239229
std::cout << "extract feat : " << ft_ptr->getLayer()->getName() << "/" << ft_ptr->getUID() << std::endl;
240230
#endif
@@ -276,11 +266,7 @@ namespace pal
276266

277267
// generate candidates for the feature part
278268
LabelPosition** lPos = NULL;
279-
int nblp = ft_ptr->setPosition( context->scale, &lPos, context->bbox_min, context->bbox_max, ft_ptr, context->candidates
280-
#ifdef _EXPORT_MAP_
281-
, *context->svgmap
282-
#endif
283-
);
269+
int nblp = ft_ptr->setPosition( context->scale, &lPos, context->bbox_min, context->bbox_max, ft_ptr, context->candidates );
284270

285271
if ( nblp > 0 )
286272
{
@@ -335,23 +321,8 @@ namespace pal
335321
return true;
336322
}
337323

338-
339-
/**
340-
* \brief Problem Factory
341-
* Select features from user's choice layers within
342-
* a specific bounding box
343-
* @param nbLayers # wanted layers
344-
* @param layersFactor layers importance
345-
* @param layersName layers in problem
346-
* @param lambda_min west bbox
347-
* @param phi_min south bbox
348-
* @param lambda_max east bbox
349-
* @param phi_max north bbox
350-
* @param scale the scale
351-
*/
352-
Problem* Pal::extract( int nbLayers, char **layersName, double *layersFactor, double lambda_min, double phi_min, double lambda_max, double phi_max, double scale, std::ofstream *svgmap )
324+
Problem* Pal::extract( int nbLayers, char **layersName, double *layersFactor, double lambda_min, double phi_min, double lambda_max, double phi_max, double scale )
353325
{
354-
Q_UNUSED( svgmap );
355326
// to store obstacles
356327
RTree<PointSet*, double, 2, double> *obstacles = new RTree<PointSet*, double, 2, double>();
357328

@@ -392,10 +363,6 @@ namespace pal
392363
context->bbox_max[0] = amax[0];
393364
context->bbox_max[1] = amax[1];
394365

395-
#ifdef _EXPORT_MAP_
396-
context->svgmap = svgmap;
397-
#endif
398-
399366
#ifdef _VERBOSE_
400367
std::cout << nbLayers << "/" << layers->size() << " layers to extract " << std::endl;
401368
std::cout << "scale is 1:" << scale << std::endl << std::endl;
@@ -436,20 +403,10 @@ namespace pal
436403
context->priority = layersFactor[i];
437404
// lookup for feature (and generates candidates list)
438405

439-
#ifdef _EXPORT_MAP_
440-
*svgmap << "<g inkscape:label=\"" << layer->name << "\"" << std::endl
441-
<< " inkscape:groupmode=\"layer\"" << std::endl
442-
<< " id=\"" << layer->name << "\">" << std::endl << std::endl;
443-
#endif
444-
445406
context->layer->mMutex.lock();
446407
context->layer->rtree->Search( amin, amax, extractFeatCallback, ( void* ) context );
447408
context->layer->mMutex.unlock();
448409

449-
#ifdef _EXPORT_MAP_
450-
*svgmap << "</g>" << std::endl << std::endl;
451-
#endif
452-
453410
#ifdef _VERBOSE_
454411
std::cout << "Layer's name: " << layer->getName() << std::endl;
455412
std::cout << " scale range: " << layer->getMinScale() << "->" << layer->getMaxScale() << std::endl;
@@ -708,35 +665,12 @@ namespace pal
708665
std::cout << std::endl << "bbox: " << bbox[0] << " " << bbox[1] << " " << bbox[2] << " " << bbox[3] << std::endl;
709666
#endif
710667

711-
#ifdef _EXPORT_MAP_
712-
// TODO this is not secure
713-
std::ofstream svgmap( "pal-map.svg" );
714-
715-
svgmap << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl
716-
<< "<svg" << std::endl
717-
<< "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"" << std::endl
718-
<< "xmlns:cc=\"http://creativecommons.org/ns#\"" << std::endl
719-
<< "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" << std::endl
720-
<< "xmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl
721-
<< "xmlns=\"http://www.w3.org/2000/svg\"" << std::endl
722-
<< "xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl
723-
<< "xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl
724-
<< "width=\"" << convert2pt( bbox[2] - bbox[0], scale, dpi ) << "\"" << std::endl
725-
<< "height=\"" << convert2pt( bbox[3] - bbox[1], scale, dpi ) << "\">" << std::endl; // TODO xmax ymax
726-
#endif
727-
728668
QTime t;
729669
t.start();
730670

731671
// First, extract the problem
732672
// TODO which is the minimum scale? (> 0, >= 0, >= 1, >1 )
733-
if ( scale < 1 || ( prob = extract( nbLayers, layersName, layersFactor, bbox[0], bbox[1], bbox[2], bbox[3], scale,
734-
#ifdef _EXPORT_MAP_
735-
& svgmap
736-
#else
737-
NULL
738-
#endif
739-
) ) == NULL )
673+
if ( scale < 1 || ( prob = extract( nbLayers, layersName, layersFactor, bbox[0], bbox[1], bbox[2], bbox[3], scale ) ) == NULL )
740674
{
741675

742676
#ifdef _VERBOSE_
@@ -746,11 +680,6 @@ namespace pal
746680
std::cout << "empty problem... finishing" << std::endl;
747681
#endif
748682

749-
#ifdef _EXPORT_MAP_
750-
svgmap << "</svg>" << std::endl;
751-
svgmap.close();
752-
#endif
753-
754683
// nothing to be done => return an empty result set
755684
if ( stats )
756685
( *stats ) = new PalStat();
@@ -799,12 +728,6 @@ namespace pal
799728
if ( stats )
800729
*stats = prob->getStats();
801730

802-
#ifdef _EXPORT_MAP_
803-
prob->drawLabels( svgmap );
804-
svgmap << "</svg>" << std::endl;
805-
svgmap.close();
806-
#endif
807-
808731
#ifdef _VERBOSE_
809732
clock_t total_time = clock() - start;
810733
std::cout << " Total time: " << double( total_time ) / double( CLOCKS_PER_SEC ) << std::endl;
@@ -847,7 +770,7 @@ namespace pal
847770
}
848771
mMutex.unlock();
849772

850-
Problem* prob = extract( nbLayers, layersName, priorities, bbox[0], bbox[1], bbox[2], bbox[3], scale, NULL );
773+
Problem* prob = extract( nbLayers, layersName, priorities, bbox[0], bbox[1], bbox[2], bbox[3], scale );
851774

852775
delete[] layersName;
853776
delete[] priorities;

0 commit comments

Comments
 (0)