<< Click to Display Table of Contents >>

 

new sg.geometry.LineString()

 

 

Description

create a line string.

 

Position

Geometry.js

 

 

Properties

 

Properties

Type

Description

extent

sg.geometry.Extent

Geometry extent

type

Number

Geometry type

length

String

line length

path

Array.<sg.geometry.Point>

Array of vertexes representing the path

 

 

Methods

 

Methods

Type

Description

addPoint(pt)

Returns: sg.geometry.Point

add vertexes

Name

Type

Description

pt

sg.geometry.Point

vertexes

toWkt()

Returns: String

return WKT string

Returns:

Type

Description

String

WKT string

getExtent()

Returns: sg.geometry.Extent

return geometry extent

Returns:

Type

Description

sg.geometry.Extent

geometry extent

getLength()

Returns: Number

return line length

Returns:

Type

Description

Number

line length

getMidPoint()

Returns: sg.geometry.Point

return the middle point of a line

Returns:

Type

Description

sg.geometry.Point

middle point of a line

setPath(path)

Returns: Array.<sg.geometry.Point>

set line path

Name

Type

Description

path

Array.<sg.geometry.Point>

An array of point

update()


update line attribute

getCentroid()

Returns: sg.geometry.Point

return the centroid of a line

Returns:

Type

Description

sg.geometry.Point

centroid of a line

Clone()

Returns: sg.geometry.LineString

Copy the geomtery object

Returns:

Type

Description

sg.geometry.LineString

line geomtery object

forEachVertex(callback)

Returns: sg.geometry.Point

Get each verttex of a line

 

callback(context)

{

 //Vertex

 Context.point;

 //Vertex index

 Context.pointIndex;

}

getFirstPoint_()

Returns: sg.geometry.point

Get the first vertex of a line

Return:

Type

Description

sg.geometry.point

first vertex of a line

 

 

Example

 

 

<script type="text/javascript" src="scripts/Geometry.js"></script>

                         

var line = new sg.geometry.LineString;

var path = [];

path.push(new sg.geometry.Point(1628256, 5728329));

path.push(new sg.geometry.Point(2101868, 5763128));

path.push(new sg.geometry.Point(2274538, 5546056));

path.push(new sg.geometry.Point(1941530, 5558390));

line.path = path;

line.update();

 

 

See live example

 


©2015 Supergeo Technologies Inc.