-1
  1. We are not able to read Multilinestring tag field from geotools.
  2. We are able to read multigeometry but its coordinate we are getting empty.

any suggestion or code snippet would really help me.

I am using below code :

static List allPlacemark = new ArrayList();

public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException {

InputStream fis = new FileInputStream(file); Parser parser = new Parser(new KMLConfiguration()); SimpleFeature documnetObject = (SimpleFeature)parser.parse(fis);

getALLPlacemark(documnetObject);

for(SimpleFeature pmark : allPlacemark){

            System.out.println(pmark);

}

}

public void getALLPlacemark(SimpleFeature sf) throws IOException, SAXException, ParserConfigurationException{

    features =  (List<SimpleFeature>) sf.getAttribute("Feature");

    if(features != null){

        Iterator<SimpleFeature> itrFeature = (Iterator<SimpleFeature>) features.iterator();

        while(itrFeature.hasNext()){

            SimpleFeature feature   =       (SimpleFeature)itrFeature.next();

            if(feature.getFeatureType().getTypeName().toString().equalsIgnoreCase("placemark") ){



                allPlacemark.add(feature);
                //System.out.println("HELLO");

            }
            getALLPlacemark(feature);

        }


    }


}
  • 1
    Are you really trying to read a literal <MultiLineString> tag? If so, that probably isn't valid KML. Can you show a simple example of what you're trying to read. Does anything work correctly? Can you parse a simple point placement? Can you show the code you're using? Have you reviewed gis.stackexchange.com/questions/4549/… ? – BradHards Feb 21 '15 at 7:13
  • added the code i am using to question. Also yes with this approach i am able to get all the details for point and linestring placemarkers. But for multigeometry placemarkers we are getting geometry collection as empty. – satpal Feb 21 '15 at 8:04
  • 2
    Please also show your KML sample. – BradHards Feb 21 '15 at 10:58
  • Below is the one of the placemark in it <Placemark> <name>1121</name> <description>ObjectId: 1121</description> <styleUrl>#CableStyle0</styleUrl> <MultiLineString> <LineString> <tessellate>1</tessellate> <altitudeMode>relativeToGround</altitudeMode> <coordinates>-71.559288,42.289148,1 -71.559231,42.289159,1 -71.557447,42.289546,1 -71.555413,42.290072,1 -71.553776,42.290425,1 -71.552536,42.29055,1 -71.550803,42.29061,1 -71.55008700000001,42.290578,1 -71.55003499999999,42.290579,1 </coordinates> </LineString> </MultiLineString> </Placemark> – satpal Feb 23 '15 at 3:40
0

I do not think your KML (per the sample in the comment) is valid, according to the KML schema.

Basically, there is no such tag as <MultiLineString>. That just never appears in the schema. There is a <MultiGeometry> which can contain 0 or more Geometry elements, including <LineString>.

MultiLineString can appear in GML 2 (it was deprecated in GML 3, but is still included for backwards compatibility), but not in KML.

Depending on the full data set, and your operational needs, you may be able to manually parse it, or use XSLT.

  • If this answers your question, could you mark it as the answer? – BradHards Feb 24 '15 at 19:40
  • not getting ow to mark it as answered. Do i need to click on answer your question ? – satpal Feb 27 '15 at 14:45
  • There should be a grey tick below the answer score and arrows. – BradHards Feb 27 '15 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.