Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

Closed Task: Labels optimizations [19912]

$
0
0
Here are some label optimizations I'm working on now.
 
LABELS DYNAMIC VISIBILITY BASED ON THE SIZE OF PARENT SHAPES
Labels dynamic visibility based on size of parent shapes
In many cases we want to see labels in case the objects they are describe are big enough.
For example when we see world map at full scale it makes sense to label only the largest cities, rivers or roads. When we zoom closer smaller ones can be labeled as well. In such a manner we shall always see the names of the most important (the largest) object first and don't be distracted on unnecessary details.
Implementation:
1. In the shapefile drawing procedure the screen size of every object can be easily calculated.
2. Then it can be stored in the shape data vector.
3. Labels.MinDrawingSize property should be added to mark minimal size of objects of label.
4. When it comes to the drawing of labels we can compare the actual size of object with this minimal value and to take the decision about its labeling.
 
SHAPEFILE/LABELS SYNCHRONIZATION
When we generate labels for shapefile, in most cases we want them to be bound to the shapes they belong to. So when shapes are added or removed, the must be updated respectively.
To make the labels work in such way it's needed:
1. Add Labels.Syncronized property. Set it to true after every automatic generation (Shapefile.GenerateLabels).
2. Prohibit the inserting and removing of the labels while Labels. Synchronized is set to true.
3. Physically store the synchronized labels in CShapefile and not in CLabels. The structure used currently in CShapefile is something like this:
ShapeData()
{
IShape* shape; // for edit mode
CFastShapeData* fastData; // for fast regular mode
bool selected;
int category;
bool isVisible;
CChartInfo* chart;
CLabelInfo* label // labels will be here!!!
long Handle; // unique handle
}
4. When label synchronized property is changed to false, copy the data to Labels class. Enable manual adding and removing of labels.
 
SYNCHRONIZATION OF POINT SHAPES WITH THEIR LABELS
When working with point shapefile (cities for example) the drawing of point should occur only in case there is place for its label (it won't be omitted by collision avoidance routine).
Otherwise there are lots of superfluous unlabeled points are drawn. Sometimes it's even difficult to say to which point the particular label belongs.
Implementation:
1. Probably the most straightforward way is to introduce the new parameter for label drawing routine like: bool CalculateSizeOnly. The collision avoidance routine will be applied there and indices of visible labels will be stored to shapeData vector in the shapefile.
2. Point drawing routine will be called which will consume the indices of visible labels as an input (and draw only corresponding points).
3. Then the labels drawing routine will be called once more. This time for actual drawing. Of course would be good to optimize it for treating only labels that were determined as visible on the first run.
4. ShapeDrawingOptions.SyncPointsWithLabels property should be added to turn this mode on and off.
Comments: There are too many various things in this one. Some of them were implemented, some not. It's faster to create a new wishlist rather than dealing with this one. Therefore closed.

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>