parent
0a5765fab8
commit
9b62a19cf4
9 changed files with 71 additions and 12 deletions
|
@ -329,6 +329,7 @@ void export_text_placement()
|
||||||
.value("LEFT",J_LEFT)
|
.value("LEFT",J_LEFT)
|
||||||
.value("MIDDLE",J_MIDDLE)
|
.value("MIDDLE",J_MIDDLE)
|
||||||
.value("RIGHT",J_RIGHT)
|
.value("RIGHT",J_RIGHT)
|
||||||
|
.value("AUTO", J_AUTO)
|
||||||
;
|
;
|
||||||
|
|
||||||
enumeration_<text_transform_e>("text_transform")
|
enumeration_<text_transform_e>("text_transform")
|
||||||
|
|
|
@ -137,6 +137,7 @@ private:
|
||||||
double first_line_space_;
|
double first_line_space_;
|
||||||
vertical_alignment_e valign_;
|
vertical_alignment_e valign_;
|
||||||
horizontal_alignment_e halign_;
|
horizontal_alignment_e halign_;
|
||||||
|
justify_alignment_e jalign_;
|
||||||
std::vector<unsigned> line_breaks_;
|
std::vector<unsigned> line_breaks_;
|
||||||
std::vector<std::pair<double, double> > line_sizes_;
|
std::vector<std::pair<double, double> > line_sizes_;
|
||||||
std::queue< box2d<double> > envelopes_;
|
std::queue< box2d<double> > envelopes_;
|
||||||
|
|
|
@ -110,6 +110,7 @@ enum justify_alignment
|
||||||
J_LEFT = 0,
|
J_LEFT = 0,
|
||||||
J_MIDDLE,
|
J_MIDDLE,
|
||||||
J_RIGHT,
|
J_RIGHT,
|
||||||
|
J_AUTO,
|
||||||
justify_alignment_MAX
|
justify_alignment_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -305,23 +305,47 @@ template <typename DetectorT>
|
||||||
void placement_finder<DetectorT>::init_alignment()
|
void placement_finder<DetectorT>::init_alignment()
|
||||||
{
|
{
|
||||||
valign_ = p.valign;
|
valign_ = p.valign;
|
||||||
if (valign_ == V_AUTO) {
|
if (valign_ == V_AUTO)
|
||||||
|
{
|
||||||
if (p.displacement.second > 0.0)
|
if (p.displacement.second > 0.0)
|
||||||
|
{
|
||||||
valign_ = V_BOTTOM;
|
valign_ = V_BOTTOM;
|
||||||
else if (p.displacement.second < 0.0)
|
} else if (p.displacement.second < 0.0)
|
||||||
|
{
|
||||||
valign_ = V_TOP;
|
valign_ = V_TOP;
|
||||||
else
|
} else
|
||||||
|
{
|
||||||
valign_ = V_MIDDLE;
|
valign_ = V_MIDDLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
halign_ = p.halign;
|
halign_ = p.halign;
|
||||||
if (halign_ == H_AUTO) {
|
if (halign_ == H_AUTO)
|
||||||
|
{
|
||||||
if (p.displacement.first > 0.0)
|
if (p.displacement.first > 0.0)
|
||||||
|
{
|
||||||
halign_ = H_RIGHT;
|
halign_ = H_RIGHT;
|
||||||
else if (p.displacement.first < 0.0)
|
} else if (p.displacement.first < 0.0)
|
||||||
|
{
|
||||||
halign_ = H_LEFT;
|
halign_ = H_LEFT;
|
||||||
else
|
} else
|
||||||
|
{
|
||||||
halign_ = H_MIDDLE;
|
halign_ = H_MIDDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jalign_ = p.jalign;
|
||||||
|
if (jalign_ == J_AUTO)
|
||||||
|
{
|
||||||
|
if (p.displacement.first > 0.0)
|
||||||
|
{
|
||||||
|
jalign_ = J_LEFT;
|
||||||
|
} else if (p.displacement.first < 0.0)
|
||||||
|
{
|
||||||
|
jalign_ = J_RIGHT;
|
||||||
|
} else {
|
||||||
|
jalign_ = J_MIDDLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,9 +413,9 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
|
||||||
if (info_.get_rtl()) y = -y;
|
if (info_.get_rtl()) y = -y;
|
||||||
|
|
||||||
// adjust for desired justification
|
// adjust for desired justification
|
||||||
if (p.jalign == J_LEFT)
|
if (jalign_ == J_LEFT)
|
||||||
x = -(string_width_ / 2.0);
|
x = -(string_width_ / 2.0);
|
||||||
else if (p.jalign == J_RIGHT)
|
else if (jalign_ == J_RIGHT)
|
||||||
x = (string_width_ / 2.0) - line_width;
|
x = (string_width_ / 2.0) - line_width;
|
||||||
else /* J_MIDDLE */
|
else /* J_MIDDLE */
|
||||||
x = -(line_width / 2.0);
|
x = -(line_width / 2.0);
|
||||||
|
@ -420,9 +444,9 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset to begining of line position
|
// reset to begining of line position
|
||||||
if (p.jalign == J_LEFT)
|
if (jalign_ == J_LEFT)
|
||||||
x = -(string_width_ / 2.0);
|
x = -(string_width_ / 2.0);
|
||||||
else if (p.jalign == J_RIGHT)
|
else if (jalign_ == J_RIGHT)
|
||||||
x = (string_width_ / 2.0) - line_width;
|
x = (string_width_ / 2.0) - line_width;
|
||||||
else
|
else
|
||||||
x = -(line_width / 2.0);
|
x = -(line_width / 2.0);
|
||||||
|
|
|
@ -40,7 +40,7 @@ text_symbolizer_properties::text_symbolizer_properties() :
|
||||||
displacement(0,0),
|
displacement(0,0),
|
||||||
label_placement(POINT_PLACEMENT),
|
label_placement(POINT_PLACEMENT),
|
||||||
halign(H_AUTO),
|
halign(H_AUTO),
|
||||||
jalign(J_MIDDLE),
|
jalign(J_AUTO),
|
||||||
valign(V_AUTO),
|
valign(V_AUTO),
|
||||||
label_spacing(0),
|
label_spacing(0),
|
||||||
label_position_tolerance(0),
|
label_position_tolerance(0),
|
||||||
|
|
|
@ -69,6 +69,7 @@ static const char * justify_alignment_strings[] = {
|
||||||
"left",
|
"left",
|
||||||
"center",
|
"center",
|
||||||
"right",
|
"right",
|
||||||
|
"auto",
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
BIN
tests/visual_tests/jalign-auto-200-reference.png
Normal file
BIN
tests/visual_tests/jalign-auto-200-reference.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
30
tests/visual_tests/jalign-auto.xml
Normal file
30
tests/visual_tests/jalign-auto.xml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE Map>
|
||||||
|
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
|
||||||
|
|
||||||
|
<Layer name="layer" srs="+proj=latlong +datum=WGS84">
|
||||||
|
<StyleName>My Style</StyleName>
|
||||||
|
<Datasource>
|
||||||
|
<Parameter name="type">shape</Parameter>
|
||||||
|
<Parameter name="file">points.shp</Parameter>
|
||||||
|
</Datasource>
|
||||||
|
</Layer>
|
||||||
|
|
||||||
|
<Style name="My Style">
|
||||||
|
<Rule>
|
||||||
|
<Filter>[nr] = '5'</Filter>
|
||||||
|
<PointSymbolizer/>
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="-30" dy="-30" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="0" dy="-30" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="30" dy="-30" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="30" dy="0" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="-30" dy="0" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="-30" dy="30" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="0" dy="30" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
<TextSymbolizer face-name="DejaVu Sans Book" size="10" placement="point" dx="30" dy="30" justify-alignment="auto">'Text line 1 line 2'</TextSymbolizer>
|
||||||
|
</Rule>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
</Map>
|
|
@ -28,7 +28,8 @@ files = [
|
||||||
("formating-4", 500),
|
("formating-4", 500),
|
||||||
("shieldsymbolizer-1", 490, 495, 497, 498, 499, 500, 501, 502, 505, 510),
|
("shieldsymbolizer-1", 490, 495, 497, 498, 499, 500, 501, 502, 505, 510),
|
||||||
("expressionformat", 500),
|
("expressionformat", 500),
|
||||||
("rtl-point", (200, 200))
|
("rtl-point", (200, 200)),
|
||||||
|
("jalign-auto", (200, 200))
|
||||||
]
|
]
|
||||||
|
|
||||||
def render(filename, width, height=100):
|
def render(filename, width, height=100):
|
||||||
|
|
Loading…
Reference in a new issue