Posted on

STMeasureToPercentage

STMeasureToPercentage — Converts supplied measure value to a percentage.

Function Specification.

Function [lrs].[STMeasureToPercentage] (
           @p_linestring geometry,
           @p_measure  Float
         )
Returns varchar(5)

Description.

The end measure minus the start measure of a measured line-string defines the range of the measures (see ST_Measure_Range).

The supplied measure is divided by this range and multiplied by 100 to return the measure as a percentage.

For non measured line-strings all values are computed using lengths.

Parameters.

    @p_linestring (geometry) - Supplied Linestring geometry.
    @p_measure     (float) - Measure somewhere within linestring.

Result.

Returns measure within measure range of linestring as percentage (0..100)

Example.

select [lrs].[STMeasureToPercentage](geometry::STGeomFromText('MULTILINESTRING((1 1 2 3, 2 2 3 4),(3 3 4 5,4 4 5 6))',0),4) as percentage
union all
select [lrs].[STMeasureToPercentage](geometry::STGeomFromText('MULTILINESTRING((1 1 2 3, 2 2 3 4),(3 3 4 5,4 4 5 6))',0),5)
union all
select [lrs].[STMeasureToPercentage](geometry::STGeomFromText('CIRCULARSTRING (3 6.325 NULL 0, 0 7 NULL 3.08, -3 6.325 NULL 6.15)',0),6.15)
GO

percentage
33.3333333333333
66.6666666666667
100
Leave a Reply

Your email address will not be published. Required fields are marked *