LineString Example - Java - Latest

Spectrum Spatial Guide

Product type
Software
Portfolio
Locate
Product family
Spectrumâ„¢ software
Product
Spectrumâ„¢ software > Spatial > Spectrum Spatial
Version
Latest
ft:locale
en-US
Product name
Spectrum Technology Platform
ft:title
Spectrum Spatial Guide
Copyright
2025
First publish date
2007
ft:lastEdition
2025-03-07
ft:lastPublication
2025-03-07T10:28:48.112000

The following shows a Java example that returns a LineString object.


public static LineString buildLineString() throws Exception
{
    LineString lineString = new LineString();
    lineString.setSrsName("EPSG:4326");
    //add the first point.
    Pos pos = new Pos();
    pos.setX(-75.44);
    pos.setY(45.66);
    pos.setMValue(new Double(54.33));
    lineString.getPos().add(pos);
    Pos pos1 = new Pos();
    pos1.setX(-73.44);
    pos1.setY(43.66);
    pos1.setMValue(new Double(54.33));
    lineString.getPos().add(pos1);
    Pos pos2 = new Pos();
    pos2.setX(-74.44);
    pos2.setY(45.66);
    pos2.setMValue(new Double(54.33));
    lineString.getPos().add(pos2);

    return lineString;
}