I’m working on a gps logger and I would like that it saves KML files. The problem with all the examples that I see, is that they append lines to the end of the file each gps update. But I want to insert lines at a specific point. Is this possible without completely rewrite the whole file?
For example, A kml file would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Paths</name>
<description>Examples of paths. Note that the tessellate tag is by default
set to 0. If you want to create tessellated lines, they must be authored
(or edited) directly in KML.</description>
<Style id="yellowLineGreenPoly">
<LineStyle>
<color>7f00ffff</color>
<width>4</width>
</LineStyle>
<PolyStyle>
<color>7f00ff00</color>
</PolyStyle>
</Style>
<Placemark>
<name>Absolute Extruded</name>
<description>Transparent green wall with yellow outlines</description>
<styleUrl>#yellowLineGreenPoly</styleUrl>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates> -112.2550785337791,36.07954952145647,2357
-112.2549277039738,36.08117083492122,2357
-112.2552505069063,36.08260761307279,2357
-112.2564540158376,36.08395660588506,2357
-112.2580238976449,36.08511401044813,2357
-112.2595218489022,36.08584355239394,2357
-112.2608216347552,36.08612634548589,2357
-112.262073428656,36.08626019085147,2357
-112.2633204928495,36.08621519860091,2357
-112.2644963846444,36.08627897945274,2357
-112.2656969554589,36.08649599090644,2357
!!! I WANT TO INSERT HERE !!!
</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
Now I want to insert new coordinates line before “”
Is this possible using the seek function? Just file.seek(filesize – bytes used for till
Followed by: file.println(new cordinates)?
In this case I trust that the last part is a fixed part of bytes. But what if I don’t know how many bytes there are after . Is there some kind of string search function in the SD library? And if so, will it be fast enough to do this a couple of times a minute?