Labelling Lines with Center justification not owrking as expected.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Labelling Lines with Center justification not owrking as expected.

blammo
All,

I’m working on a Parcel Assessment app that will display Parcel edges and which streets they abut.  I’m trying to label each edge of the parcel with it’s Edge length, but the positioning of the labels is not at all what I’m expecting in the output.  Here is a sample image:


The blue lines represent a connection from the center of each of the parcel edge segments being assigned, to the approriate Street/Alley centerline (not shown).  I can’t seem to get the labels to center them selves on the segments.  There should be one distance label centered on each segment at the start of each of the blue lines where they intersect the red parcel edges.

My next workaround would be to use a centroid of the line as the label point.  I think I’ve tried all available combinations of settings in the Mapfile, but maybe I missed something.  

Anyone have any ideas?

Here is the Label layer for the Parcel edges:

LAYER
NAME 'Parcels-Query-Edges'
STATUS ON
TYPE LINE

METADATA
"ows_title" "Parcels-Query-Edges"
"gml_include_items" "all"
END

CONNECTIONTYPE PostGIS
CONNECTION “***REMOVED***”
DATA "geom from (
select 
round(length::numeric,2) round_el,
* from assessment.rc_parcel_segments_no_overlaps 
WHERE parcelid = '%pin%'
OR parcelid = '%qstring%'
) as subquery using unique segid srid=200068"

PROJECTION
"init=epsg:200068"
END

CLASSITEM "parcelid"
LABELITEM "round_el"

VALIDATION
'pin' '^[0-9]{12}$'
'qstring' '^[0-9]{12}$'
END

CLASS
STYLE
GEOMTRANSFORM "start"
SYMBOL "circle"
COLOR 255 0 0
SIZE 12
END
STYLE
GEOMTRANSFORM "end"
SYMBOL "circle"
COLOR 255 0 0
SIZE 12
END # STYLE
LABEL
FORCE true
COLOR  255 0 0
OUTLINECOLOR 255 255 255
FONT "arial-bold"
TYPE truetype
SIZE 12
ANGLE auto
POSITION auto
END
END # CLASS
TEMPLATE 'TEMPLATES/empty.html'
END # LAYER

Thanks

bobb






"Reality is merely an illusion, albeit a very persistent one."
- Albert Einstein 




_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Labelling Lines with Center justification not owrking as expected.

Stephen Woodbridge
On 8/24/2017 5:47 PM, Basques, Bob (CI-StPaul) wrote:

> All,
>
> I’m working on a Parcel Assessment app that will display Parcel edges
> and which streets they abut.  I’m trying to label each edge of the
> parcel with it’s Edge length, but the positioning of the labels is not
> at all what I’m expecting in the output.  Here is a sample image:
>
> https://www.dropbox.com/s/ppp1cihnl4flycf/rc_parcels_assessment.02.png?dl=0
>
> The blue lines represent a connection from the center of each of the
> parcel edge segments being assigned, to the approriate Street/Alley
> centerline (not shown).  I can’t seem to get the labels to center them
> selves on the segments.  There should be one distance label centered on
> each segment at the start of each of the blue lines where they intersect
> the red parcel edges.
>
> My next workaround would be to use a centroid of the line as the label
> point.  I think I’ve tried all available combinations of settings in the
> Mapfile, but maybe I missed something.
>
> Anyone have any ideas?

In the LABEL use a geotransform "center" to create the label point, but
this has the problem that you have a point so you have to precompute the
ANGLE [angle] in the SQL and make that available to align the label with
the edge.

-Steve W

> Here is the Label layer for the Parcel edges:
>
> LAYER
> NAME 'Parcels-Query-Edges'
> STATUS ON
> TYPE LINE
>
> METADATA
> "ows_title" "Parcels-Query-Edges"
> "gml_include_items" "all"
> END
>
> CONNECTIONTYPE PostGIS
> CONNECTION “***REMOVED***”
> DATA "geom from (
> select
> round(length::numeric,2) round_el,
> * from assessment.rc_parcel_segments_no_overlaps
> WHERE parcelid = '%pin%'
> OR parcelid = '%qstring%'
> ) as subquery using unique segid srid=200068"
>
> PROJECTION
> "init=epsg:200068"
> END
>
> CLASSITEM "parcelid"
> LABELITEM "round_el"
>
> VALIDATION
> 'pin' '^[0-9]{12}$'
> 'qstring' '^[0-9]{12}$'
> END
>
> CLASS
> STYLE
> GEOMTRANSFORM "start"
> SYMBOL "circle"
> COLOR 255 0 0
> SIZE 12
> END
> STYLE
> GEOMTRANSFORM "end"
> SYMBOL "circle"
> COLOR 255 0 0
> SIZE 12
> END # STYLE
> LABEL
> FORCE true
> COLOR  255 0 0
> OUTLINECOLOR 255 255 255
> FONT "arial-bold"
> TYPE truetype
> SIZE 12
> ANGLE auto
> POSITION auto
> END
> END # CLASS
> TEMPLATE 'TEMPLATES/empty.html'
> END # LAYER
>
> Thanks
>
> bobb
>
>
>
>
>
>
> "Reality is merely an illusion, albeit a very persistent one."
>     - Albert Einstein
>
>
>
>
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Labelling Lines with Center justification not owrking as expected.

blammo
Steve,

Doesn’t look like there is a LABEL option avaiable for GEOMTRANSFORM.  All needs to be inside of the STYLE block.  I tried wrapping it in a STYLE block inside of the Label, and got back:

<ServiceException>
msDrawLabelCAche(): General error message. Labels only support LABELPNT and LABELPOLY GEOMTRANSFORMS
</ServiceException>

I also tried “center” and “centroid” as parameters. . . .

bobb




On Aug 24, 2017, at 7:29 PM, Stephen Woodbridge <[hidden email]> wrote:

On 8/24/2017 5:47 PM, Basques, Bob (CI-StPaul) wrote:
All,
I’m working on a Parcel Assessment app that will display Parcel edges and which streets they abut.  I’m trying to label each edge of the parcel with it’s Edge length, but the positioning of the labels is not at all what I’m expecting in the output. Here is a sample image:
https://www.dropbox.com/s/ppp1cihnl4flycf/rc_parcels_assessment.02.png?dl=0
The blue lines represent a connection from the center of each of the parcel edge segments being assigned, to the approriate Street/Alley centerline (not shown).  I can’t seem to get the labels to center them selves on the segments.  There should be one distance label centered on each segment at the start of each of the blue lines where they intersect the red parcel edges.
My next workaround would be to use a centroid of the line as the label point.  I think I’ve tried all available combinations of settings in the Mapfile, but maybe I missed something.
Anyone have any ideas?

In the LABEL use a geotransform "center" to create the label point, but this has the problem that you have a point so you have to precompute the ANGLE [angle] in the SQL and make that available to align the label with the edge.

-Steve W

Here is the Label layer for the Parcel edges:
LAYER
NAME 'Parcels-Query-Edges'
STATUS ON
TYPE LINE
METADATA
"ows_title" "Parcels-Query-Edges"
"gml_include_items" "all"
END
CONNECTIONTYPE PostGIS
CONNECTION “***REMOVED***”
DATA "geom from (
select
round(length::numeric,2) round_el,
* from assessment.rc_parcel_segments_no_overlaps
WHERE parcelid = '%pin%'
OR parcelid = '%qstring%'
) as subquery using unique segid srid=200068"
PROJECTION
"init=epsg:200068"
END
CLASSITEM "parcelid"
LABELITEM "round_el"
VALIDATION
'pin' '^[0-9]{12}$'
'qstring' '^[0-9]{12}$'
END
CLASS
STYLE
GEOMTRANSFORM "start"
SYMBOL "circle"
COLOR 255 0 0
SIZE 12
END
STYLE
GEOMTRANSFORM "end"
SYMBOL "circle"
COLOR 255 0 0
SIZE 12
END # STYLE
LABEL
FORCE true
COLOR  255 0 0
OUTLINECOLOR 255 255 255
FONT "arial-bold"
TYPE truetype
SIZE 12
ANGLE auto
POSITION auto
END
END # CLASS
TEMPLATE 'TEMPLATES/empty.html'
END # LAYER
Thanks
bobb
"Reality is merely an illusion, albeit a very persistent one."
   - Albert Einstein
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users



Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry




_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Labelling Lines with Center justification not owrking as expected.

blammo
Ok, at least now they are in the right spot.

https://www.dropbox.com/s/tsyr3p0zyui65cb/rc_parcels_assessment.02b.png?dl=0

GEOMTRANSFORM doesn’t seem to work on Lines . . . so . . . 

I added a layer just for the Label point from the original line segments in Postgres . . .

        LAYER
NAME 'Parcels-Query-Edges-Label'
STATUS ON
TYPE POINT

METADATA
"ows_title" "Parcels-Query-Edges-Label"
"gml_include_items" "all"
END

CONNECTIONTYPE PostGIS
CONNECTION “host=localhost dbname=postgres user=mapserv password=***”
DATA "geom from (
select   
ST_Centroid(geom) geom,
round(length::numeric,2) round_el,
segid, parcelid, length from assessment.rc_parcel_segments_no_overlaps 
WHERE parcelid = '%pin%'
OR parcelid = '%qstring%'
) as subquery using unique segid srid=200068"

PROJECTION
"init=epsg:200068"
END

CLASSITEM "parcelid"
LABELITEM "round_el"

LABELCACHE on

VALIDATION
'pin' '^[0-9]{12}$'
'qstring' '^[0-9]{12}$'
END

CLASS
LABEL
FORCE true
COLOR  0 255 0
OUTLINECOLOR 255 255 255
FONT "arial-bold"
TYPE truetype
SIZE 12
ANGLE auto
POSITION uc
END
END # CLASS
TEMPLATE 'TEMPLATES/empty.html'
END # LAYER


bobb






On Aug 25, 2017, at 10:56 AM, Basques, Bob (CI-StPaul) <[hidden email]> wrote:

Steve,

Doesn’t look like there is a LABEL option avaiable for GEOMTRANSFORM.  All needs to be inside of the STYLE block.  I tried wrapping it in a STYLE block inside of the Label, and got back:

<ServiceException>
msDrawLabelCAche(): General error message. Labels only support LABELPNT and LABELPOLY GEOMTRANSFORMS
</ServiceException>

I also tried “center” and “centroid” as parameters. . . .

bobb




On Aug 24, 2017, at 7:29 PM, Stephen Woodbridge <[hidden email]> wrote:

On 8/24/2017 5:47 PM, Basques, Bob (CI-StPaul) wrote:
All,
I’m working on a Parcel Assessment app that will display Parcel edges and which streets they abut.  I’m trying to label each edge of the parcel with it’s Edge length, but the positioning of the labels is not at all what I’m expecting in the output. Here is a sample image:
https://www.dropbox.com/s/ppp1cihnl4flycf/rc_parcels_assessment.02.png?dl=0
The blue lines represent a connection from the center of each of the parcel edge segments being assigned, to the approriate Street/Alley centerline (not shown).  I can’t seem to get the labels to center them selves on the segments.  There should be one distance label centered on each segment at the start of each of the blue lines where they intersect the red parcel edges.
My next workaround would be to use a centroid of the line as the label point.  I think I’ve tried all available combinations of settings in the Mapfile, but maybe I missed something.
Anyone have any ideas?

In the LABEL use a geotransform "center" to create the label point, but this has the problem that you have a point so you have to precompute the ANGLE [angle] in the SQL and make that available to align the label with the edge.

-Steve W

Here is the Label layer for the Parcel edges:
LAYER
NAME 'Parcels-Query-Edges'
STATUS ON
TYPE LINE
METADATA
"ows_title" "Parcels-Query-Edges"
"gml_include_items" "all"
END
CONNECTIONTYPE PostGIS
CONNECTION “***REMOVED***”
DATA "geom from (
select
round(length::numeric,2) round_el,
* from assessment.rc_parcel_segments_no_overlaps
WHERE parcelid = '%pin%'
OR parcelid = '%qstring%'
) as subquery using unique segid srid=200068"
PROJECTION
"init=epsg:200068"
END
CLASSITEM "parcelid"
LABELITEM "round_el"
VALIDATION
'pin' '^[0-9]{12}$'
'qstring' '^[0-9]{12}$'
END
CLASS
STYLE
GEOMTRANSFORM "start"
SYMBOL "circle"
COLOR 255 0 0
SIZE 12
END
STYLE
GEOMTRANSFORM "end"
SYMBOL "circle"
COLOR 255 0 0
SIZE 12
END # STYLE
LABEL
FORCE true
COLOR  255 0 0
OUTLINECOLOR 255 255 255
FONT "arial-bold"
TYPE truetype
SIZE 12
ANGLE auto
POSITION auto
END
END # CLASS
TEMPLATE 'TEMPLATES/empty.html'
END # LAYER
Thanks
bobb
"Reality is merely an illusion, albeit a very persistent one."
   - Albert Einstein
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users



Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry



_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users



An inventor is simply a fellow who doesn’t take his education too seriously.
—Charles F. Kettering


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Labelling Lines with Center justification not owrking as expected.

Stephen Woodbridge
In reply to this post by blammo
bobb,

Ok, then I think you should probably compute a point, label, angle
columns in the SQL and then use these to generate the label

Something like:

LAYER
   TYPE POINT
   ...
   DATA "geom from ( select gid, st_centroid(geom) as geom, format(...,
st_length(geom)*convert2units), st_azimuth(geom) as angle from table )
as subquery using unique segid srid=200068"
   LABELITEM "label"
   CLASS
     LABEL
       ANGLE [angle]
       ...
     END
   END
END



On 8/25/2017 11:56 AM, Basques, Bob (CI-StPaul) wrote:

> Steve,
>
> Doesn’t look like there is a LABEL option avaiable for GEOMTRANSFORM.
>   All needs to be inside of the STYLE block.  I tried wrapping it in a
> STYLE block inside of the Label, and got back:
>
> <ServiceException>
> msDrawLabelCAche(): General error message. Labels only support LABELPNT
> and LABELPOLY GEOMTRANSFORMS
> </ServiceException>
>
> I also tried “center” and “centroid” as parameters. . . .
>
> bobb
>
>
>
>
>> On Aug 24, 2017, at 7:29 PM, Stephen Woodbridge
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> On 8/24/2017 5:47 PM, Basques, Bob (CI-StPaul) wrote:
>>> All,
>>> I’m working on a Parcel Assessment app that will display Parcel edges
>>> and which streets they abut.  I’m trying to label each edge of the
>>> parcel with it’s Edge length, but the positioning of the labels is
>>> not at all what I’m expecting in the output. Here is a sample image:
>>> https://www.dropbox.com/s/ppp1cihnl4flycf/rc_parcels_assessment.02.png?dl=0
>>> The blue lines represent a connection from the center of each of the
>>> parcel edge segments being assigned, to the approriate Street/Alley
>>> centerline (not shown).  I can’t seem to get the labels to center
>>> them selves on the segments.  There should be one distance label
>>> centered on each segment at the start of each of the blue lines where
>>> they intersect the red parcel edges.
>>> My next workaround would be to use a centroid of the line as the
>>> label point.  I think I’ve tried all available combinations of
>>> settings in the Mapfile, but maybe I missed something.
>>> Anyone have any ideas?
>>
>> In the LABEL use a geotransform "center" to create the label point,
>> but this has the problem that you have a point so you have to
>> precompute the ANGLE [angle] in the SQL and make that available to
>> align the label with the edge.
>>
>> -Steve W
>>
>>> Here is the Label layer for the Parcel edges:
>>> LAYER
>>> NAME 'Parcels-Query-Edges'
>>> STATUS ON
>>> TYPE LINE
>>> METADATA
>>> "ows_title" "Parcels-Query-Edges"
>>> "gml_include_items" "all"
>>> END
>>> CONNECTIONTYPE PostGIS
>>> CONNECTION “***REMOVED***”
>>> DATA "geom from (
>>> select
>>> round(length::numeric,2) round_el,
>>> * from assessment.rc_parcel_segments_no_overlaps
>>> WHERE parcelid = '%pin%'
>>> OR parcelid = '%qstring%'
>>> ) as subquery using unique segid srid=200068"
>>> PROJECTION
>>> "init=epsg:200068"
>>> END
>>> CLASSITEM "parcelid"
>>> LABELITEM "round_el"
>>> VALIDATION
>>> 'pin' '^[0-9]{12}$'
>>> 'qstring' '^[0-9]{12}$'
>>> END
>>> CLASS
>>> STYLE
>>> GEOMTRANSFORM "start"
>>> SYMBOL "circle"
>>> COLOR 255 0 0
>>> SIZE 12
>>> END
>>> STYLE
>>> GEOMTRANSFORM "end"
>>> SYMBOL "circle"
>>> COLOR 255 0 0
>>> SIZE 12
>>> END # STYLE
>>> LABEL
>>> FORCE true
>>> COLOR  255 0 0
>>> OUTLINECOLOR 255 255 255
>>> FONT "arial-bold"
>>> TYPE truetype
>>> SIZE 12
>>> ANGLE auto
>>> POSITION auto
>>> END
>>> END # CLASS
>>> TEMPLATE 'TEMPLATES/empty.html'
>>> END # LAYER
>>> Thanks
>>> bobb
>>> "Reality is merely an illusion, albeit a very persistent one."
>>>    - Albert Einstein
>>> _______________________________________________
>>> mapserver-users mailing list
>>> [hidden email] <mailto:[hidden email]>
>>> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>>
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>>
>> _______________________________________________
>> mapserver-users mailing list
>> [hidden email] <mailto:[hidden email]>
>> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
> Perfection is achieved, not when there is nothing more to add, but when
> there is nothing left to take away.
> —Antoine de Saint-Exupéry
>
>
>

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users