Posted on

STIsPseudoMultiCurve

STIsPseudoMultiCurve — Checks if supplied @p_geometry is a GeometryCollection object containing only LineString, CircularString and CompoundCurve elements.

Function Specification.

Function [dbo].[STIsPseudoMultiCurve] (
                  @p_geometry geometry
         )
Returns bit

Description.

This function checks if the supplied @p_geometry is a GeometryCollection object containing only LineString, CircularString and CompoundCurve elements.

One cannot create a MultiLineString object where an element is a CircularString or CompoundCurve.

Any attempt to do so causes the GeometryType to be set to GeometryCollection rather than MultiLineString or MultiCurve.

If these sorts of GeometryCollection objects are not supported, it is impossible to represent a MultiLine object with a mix of CircularCurve and LineString types.

The function returns 1 (true) if provided geometry is a pseudo MultiCurve (or MultiLineString).

Parameters.

    @p_geometry (geometry) - GeometryCollection or MultiLineString.

Result.

This function returns 1 (true) if @_geometry is a pseudo MultiCurve, 0 (false) otherwise.

Example.

-- This is how SQL Server merges a LineString and a CircularString that do not touch
-- 
SELECT geometry::STGeomFromText('LINESTRING(0 0 0 5.6, 5 5 0 6.3,5 10 0 9.6)',0)
       .STUnion(
         geometry::STGeomFromText('CIRCULARSTRING(-0.5 -0.5 0 5.6,-0.2 -0.4 0 5.5, -0.1 -0.1 0 5.65)',0)
       ).AsTextZM() as MultiCurve;
GO

MultiCurve
--------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION (LINESTRING (5 10, 5 5, 0 0), CIRCULARSTRING (-0.5 -0.5, -0.2 -0.4, -0.1 -0.1))

-- Note that STUnion removes Z and M ordinates

-- Now put result through STIsPseudoMultiCurve
-- 
SELECT [dbo].STIsPseudoMultiCurve] ( geometry::STGeomFromText('GEOMETRYCOLLECTION (LINESTRING (5 10, 5 5, 0 0), CIRCULARSTRING (-0.5 -0.5, -0.2 -0.4, -0.1 -0.1))',0)) as isMultiCurve
GO

isMultiCurve
------------
1
Posted on

STScale

STScale is a TSQL function that moves a geometry object’s ordinates using the supplied delta X, Y, Z and M.

Function Specification.

Function [dbo].[STScale] (
           @p_geometry geometry,
           @p_xFactor  float,
           @p_yFactor  float,
           @p_zFactor  float,
           @p_mFactor  float,
           @p_round_xy int = 3,
           @p_round_zm int = 2 
         )
Returns geometry 

Example.

-- XY
SELECT [dbo].[STScale](
               geometry::STGeomFromText('LINESTRING(0.1 0.2,1.4 45.2)',0),
               -5.0,
                3.2,
                NULL,
                NULL,
                3,
                2
       ).AsTextZM() as scaledGeom;

scaledGeom
LINESTRING (-0.5 0.64, -7 144.64)

-- XYZ
SELECT [dbo].[STScale](
               geometry::STGeomFromText('LINESTRING(0.1 0.2 NULL 1.0,1.4 45.2 NULL 45.02)',0),
                NULL,
                NULL,
                NULL,
                1.5,
                3,
                2
       ).AsTextZM() as scaledGeom;

scaledGeom
LINESTRING (0.1 0.2 NULL 1.5, 1.4 45.2 NULL 67.53)

-- XYZM
SELECT [dbo].[STScale](
               geometry::STGeomFromText('LINESTRING(0.1 0.2 0.9 1.0,1.4 45.2 2.1 45.02)',0),
                1.0,
                1.0,
                2.0,
                1.5,
                3,
                2
       ).AsTextZM() as scaledGeom;

scaledGeom
LINESTRING (0.1 0.2 1.8 1.5, 1.4 45.2 4.2 67.53)

Description.

This function scales the supplied geometry’s ordinates using the supplied scale factors.

The computed ordinates of the new geometry are rounded to the appropriate decimal digits of precision.

Parameters.

    @p_geometry (geometry) - supplied geometry of any type.
    @p_xFactor  (double)   - X ordinate scale factor.
    @p_yFactor  (double)   - Y ordinate scale factor.
    @p_zFactor  (double)   - Z ordinate scale factor.
    @p_mFactor  (double)   - M ordinate scale factor.
    @p_round_xy (int)      - Decimal degrees of precision to which calculated XY ordinates are rounded.
    @p_round_zm (int)      - Decimal degrees of precision to which calculated XM ordinates are rounded.

Results.

The function returns the input geometry scaled by supplied ordinate factor values.

Posted on

STMove

STMoveis a function that moves a geometry using the supplied delta X, Y, Z and M ordinate values.

TSQL Function Specification.

Function STMove (
           @p_geometry geometry,
           @p_dX       float,
           @p_dY       float,
           @p_dZ       float,
           @p_dM       float,
           @p_round_xy int = 3,
           @p_round_zm int = 2
         )
Returns geometry

Description.

The STMove function moves the supplied geometry’s ordinates using the supplied x, y, z and m delta ordinate values.

The computed ordinates of the new geometry are rounded to @p_round_xy/@p_round_zm number of decimal digits of precision.

Parameters.

    @p_geometry (geometry) - Supplied geometry of any type.
    @p_dX          (float) - X ordinate delta shift.
    @p_dy          (float) - Y ordinate delta shift.
    @p_dZ          (float) - Z ordinate delta shift.
    @p_dM          (float) - M ordinate delta shift.
    @p_round_xy      (int) - Decimal degrees of precision to which calculated XY ordinates are rounded.
    @p_round_zm      (int) - Decimal degrees of precision to which calculated ZM ordinates are rounded.

Result.

The function moves the input geometry by supplied ordinate deltas.

Example.

SELECT [dbo].[STMove](geometry::ST_GeomFromText('LINESTRING(0.1 0.2,1.4 45.2)',0),-5.0,30.1,default,default,2,1).AsTextZM() as movedGeom
GO

movedGeom
'LINESTRING(-4.9 30.2,-3.6 31.5)'
Posted on

Change Log

2019-07-19: SQL Server Spatial.

    Corrected installation errors
    Fixed STPointFromText null Z with M handling
    Moved all PostGIS LRS functions into a single script.
    Added STLocateBetweenElevations, STLineSubstring, and STLineInterpolatePoint
    Modified STExtract to extract polygon ring sub elements where ring defined using CircularCurve or CompoundCurve.
    Modified STIsMeasureDecreasing
    Modified STCogo2Line
    Improved function documentation.
    Updated html documentation.

2019-05-17: Created SQL Server Spatial STDensify and STGeometryTypes functions.

2019-01-12: Created install.sh Linux bash script for Oracle PLSQL Object code.