Rev 27 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 27 | Rev 41 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
5 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
6 | // + Nur für den privaten Gebrauch |
6 | // + Nur für den privaten Gebrauch |
7 | // + FOR NON COMMERCIAL USE ONLY |
7 | // + FOR NON COMMERCIAL USE ONLY |
8 | // + www.MikroKopter.com |
8 | // + www.MikroKopter.com |
9 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
9 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
10 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
10 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
11 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
11 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
12 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
12 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
13 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
13 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
14 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
14 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
15 | // + Verkauf von Luftbildaufnahmen, usw. |
15 | // + Verkauf von Luftbildaufnahmen, usw. |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
17 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
17 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
18 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
18 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
20 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
21 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
21 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
22 | // + eindeutig als Ursprung verlinkt werden |
22 | // + eindeutig als Ursprung verlinkt werden |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
24 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
24 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
25 | // + Benutzung auf eigene Gefahr |
25 | // + Benutzung auf eigene Gefahr |
26 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
26 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
28 | // + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
28 | // + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
29 | // + mit unserer Zustimmung zulässig |
29 | // + mit unserer Zustimmung zulässig |
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
31 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
31 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
32 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
32 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
33 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
33 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
34 | // + this list of conditions and the following disclaimer. |
34 | // + this list of conditions and the following disclaimer. |
35 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
35 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
36 | // + from this software without specific prior written permission. |
36 | // + from this software without specific prior written permission. |
37 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
37 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
38 | // + for non-commercial use (directly or indirectly) |
38 | // + for non-commercial use (directly or indirectly) |
39 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
39 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
40 | // + with our written permission |
40 | // + with our written permission |
41 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
41 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
42 | // + clearly linked as origin |
42 | // + clearly linked as origin |
43 | // + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
43 | // + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
44 | // |
44 | // |
45 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
45 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
46 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
46 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
47 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
47 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
Line 50... | Line 50... | ||
50 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
50 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
51 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
51 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
52 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
52 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
53 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
53 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
54 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
54 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
55 | // + POSSIBILITY OF SUCH DAMAGE. |
55 | // + POSSIBILITY OF SUCH DAMAGE. |
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
57 | - | ||
- | 57 | #include <stdlib.h> |
|
58 | #include <stdio.h> |
58 | #include <stdio.h> |
59 | #include "main.h" |
59 | #include "91x_lib.h" |
60 | #include "kml.h" |
60 | #include "kml.h" |
61 | #include "kml_header.h" |
61 | #include "kml_header.h" |
62 | #include "fat16.h" |
- | |
Line 63... | Line 62... | ||
63 | 62 | ||
64 | 63 | ||
65 | //________________________________________________________________________________________________________________________________________ |
64 | //________________________________________________________________________________________________________________________________________ |
66 | // Module name: kml.c |
65 | // Module name: kml.c |
67 | // Compiler used: avr-gcc 3.4.5 |
66 | // Compiler used: avr-gcc 3.4.5 |
68 | // Last Modifikation: 17.03.2008 |
67 | // Last Modifikation: 20.07.2008 |
69 | // Version: 1.02 |
68 | // Version: 1.02 |
70 | // Authors: Stephan Busker |
69 | // Authors: Stephan Busker |
71 | // Description: Source files to write gps-coordinates to a file in the kml (keyhole markup language) fileformat |
70 | // Description: Source files to write gps-coordinates to a file in the kml (keyhole markup language) fileformat |
72 | // Copyright (C) 2007 Stephan Busker |
71 | // Copyright (C) 2007 Stephan Busker |
73 | //........................................................................................................................................ |
72 | //........................................................................................................................................ |
74 | // Functions: extern u8 KML_LoggGPSCoordinates(struct str_gps_nav_data , KML_Document_t *); // intializes the kml-document with standard filename and adds points to the file |
73 | // Functions: extern u8 KML_LoggGPSCoordinates(struct str_gps_nav_data , KML_Document_t *); // intializes the kml-document with standard filename and adds points to the file |
75 | // extern u8 KML_DocumentInit(KML_Document_t *doc) // initializes the kml-document to resetvalues. |
74 | // extern u8 KML_DocumentInit(KML_Document_t *doc) // initializes the kml-document to resetvalues. |
76 | // extern u8 KML_DocumentOpen(s8 *, KML_Document_t *); // opens a new kml document. A filename can be specified. |
75 | // extern u8 KML_DocumentOpen(s8 *, KML_Document_t *); // opens a new kml document. A filename can be specified. |
77 | // extern u8 KML_DocumentClose(KML_Document_t *doc); // closes an open document |
76 | // extern u8 KML_DocumentClose(KML_Document_t *doc); // closes an open document |
78 | // extern u8 KML_PlaceMarkOpen(s8 *name, KML_Document_t *); // opens a new placemark within the specified document |
77 | // extern u8 KML_PlaceMarkOpen(s8 *name, KML_Document_t *); // opens a new placemark within the specified document |
79 | // extern u8 KML_PlaceMarkClose( KML_Document_t *); // Closes the placemark |
78 | // extern u8 KML_PlaceMarkClose( KML_Document_t *); // Closes the placemark |
80 | // extern u8 KML_LineStringBegin(KML_Document_t *); // begins a new line within the actual placemark |
79 | // extern u8 KML_LineStringBegin(KML_Document_t *); // begins a new line within the actual placemark |
81 | // extern u8 KML_LineStringEnd(KML_Document_t *doc); // ends the actual linestring |
80 | // extern u8 KML_LineStringEnd(KML_Document_t *doc); // ends the actual linestring |
82 | // extern u8 KML_LineStringAddPoint(struct str_gps_nav_data, KML_Document_t *); // adds a new point (gps-coordinates) to the actual linestring |
81 | // extern u8 KML_LineStringAddPoint(struct str_gps_nav_data, KML_Document_t *); // adds a new point (gps-coordinates) to the actual linestring |
83 | //........................................................................................................................................ |
82 | //........................................................................................................................................ |
84 | // ext. functions: |
83 | // ext. functions: |
85 | // |
84 | // |
86 | //........................................................................................................................................ |
85 | //........................................................................................................................................ |
87 | // |
86 | // |
88 | // URL: www.Mikro-Control.de |
87 | // URL: www.Mikro-Control.de |
Line 89... | Line 88... | ||
89 | // mailto: stephan.busker@mikro-control.de |
88 | // mailto: stephan.busker@mikro-control.de |
90 | //________________________________________________________________________________________________________________________________________ |
89 | //________________________________________________________________________________________________________________________________________ |
91 | 90 | ||
92 | 91 | ||
93 | 92 | ||
94 | //________________________________________________________________________________________________________________________________________ |
93 | //________________________________________________________________________________________________________________________________________ |
95 | // Funtion: KML_DocumentInit(KML_Document_t *) |
94 | // Function: KML_DocumentInit(KML_Document_t *) |
96 | // |
95 | // |
Line 97... | Line 96... | ||
97 | // Description: This function initializes the kml-document for further use. |
96 | // Description: This function initializes the kml-document for further use. |
98 | // |
97 | // |
99 | // |
98 | // |
100 | // Returnvalue: '1' if document was initialized |
99 | // Returnvalue: '1' if document was initialized |
101 | //________________________________________________________________________________________________________________________________________ |
100 | //________________________________________________________________________________________________________________________________________ |
102 | 101 | ||
103 | u8 KML_DocumentInit(KML_Document_t *doc) |
102 | u8 KML_DocumentInit(KML_Document_t *doc) |
104 | { |
103 | { |
105 | doc->name[0] = 0; // name of the document |
104 | doc->name[0] = 0; // name of the document |
Line 106... | Line 105... | ||
106 | doc->state = DOC_CLOSED; // state of the kml-document |
105 | doc->state = DOC_CLOSED; // state of the kml-document |
107 | doc->file = NULL; |
106 | doc->file = NULL; |
108 | doc->place.name[0]=0; |
107 | doc->place.name[0]=0; |
109 | doc->place.description[0]=0; |
108 | doc->place.description[0]=0; |
110 | return(1); |
- | |
111 | } |
109 | return(1); |
- | 110 | } |
|
112 | 111 | ||
113 | //________________________________________________________________________________________________________________________________________ |
112 | //________________________________________________________________________________________________________________________________________ |
Line 114... | Line 113... | ||
114 | // Funtion: KML_Document_Open(void); |
113 | // Function: KML_Document_Open(void); |
115 | // |
114 | // |
Line 116... | Line 115... | ||
116 | // Description: This function opens a new KML- document with the specified name and creates the document header within the file. |
115 | // Description: This function opens a new KML- document with the specified name and creates the document header within the file. |
117 | // |
116 | // |
- | 117 | // |
|
- | 118 | // Returnvalue: '1' if the KML- file could be created. |
|
118 | // |
119 | //________________________________________________________________________________________________________________________________________ |
119 | // Returnvalue: '1' if the KML- file could be created. |
120 | |
Line 120... | Line 121... | ||
120 | //________________________________________________________________________________________________________________________________________ |
121 | u8 KML_DocumentOpen(s8 *name, KML_Document_t *doc) |
121 | 122 | { |
|
122 | u8 KML_DocumentOpen(s8 *name, KML_Document_t *doc) |
123 | |
123 | { |
124 | u8 retvalue = 0; |
124 | 125 | ||
125 | u8 retvalue = 0; |
126 | if(doc == NULL) return(0); |
Line 126... | Line 127... | ||
126 | 127 | ||
127 | KML_DocumentInit(doc); // intialize the document with resetvalues |
128 | KML_DocumentInit(doc); // intialize the document with resetvalues |
Line 128... | Line 129... | ||
128 | doc->file = fopen_(name,'a'); // open a new file with the specified filename on the memorycard. |
129 | doc->file = fopen_(name,'a'); // open a new file with the specified filename on the memorycard. |
129 | 130 | ||
130 | if(doc->file != NULL) // could the file be opened? |
131 | if(doc->file != NULL) // could the file be opened? |
131 | { |
132 | { |
132 | retvalue = 1; // the document could be created on the drive. |
- | |
133 | doc->state = DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
133 | retvalue = 1; // the document could be created on the drive. |
- | 134 | doc->state = DOC_OPENED; // change document state to opened. At next a placemark has to be opened. |
|
134 | fwrite_(KML_DOCUMENT_HEADER, sizeof(KML_DOCUMENT_HEADER)-1,1,doc->file); // write the KML- footer to the document. |
135 | fwrite_((void*)KML_DOCUMENT_HEADER, sizeof(KML_DOCUMENT_HEADER)-1,1,doc->file);// write the KML- footer to the document. |
135 | } |
136 | } |
Line 136... | Line 137... | ||
136 | 137 | ||
137 | return(retvalue); |
138 | return(retvalue); |
Line 138... | Line 139... | ||
138 | } |
139 | } |
- | 140 | ||
- | 141 | //________________________________________________________________________________________________________________________________________ |
|
Line 139... | Line 142... | ||
139 | 142 | // Function: DocumentClose(KML_Document_t *doc); |
|
140 | //________________________________________________________________________________________________________________________________________ |
143 | // |
141 | // Funtion: DocumentClose(KML_Document_t *doc); |
144 | // Description: This function closes the document specified by doc. |
142 | // |
145 | // |
143 | // Description: This function closes the document specified by doc. |
146 | // |
144 | // |
147 | // Returnvalue: '1' if the KML- file could be closed. |
145 | // |
148 | //________________________________________________________________________________________________________________________________________ |
146 | // Returnvalue: none |
149 | |
Line 147... | Line 150... | ||
147 | //________________________________________________________________________________________________________________________________________ |
150 | u8 KML_DocumentClose(KML_Document_t *doc) |
148 | 151 | { |
|
149 | u8 KML_DocumentClose(KML_Document_t *doc) |
152 | |
150 | { |
153 | u8 retvalue = 1; |
151 | 154 | ||
152 | u8 retvalue = 0; |
155 | if(doc == NULL) return(0); |
153 | 156 | ||
154 | while(doc->state != DOC_CLOSED) // close linestring, placemark and document before closing the file on the memorycard |
157 | while(doc->state != DOC_CLOSED) // close linestring, placemark and document before closing the file on the memorycard |
155 | { |
158 | { |
156 | switch(doc->state) |
159 | switch(doc->state) |
157 | { |
160 | { |
158 | case DOC_LINESTRING_OPENED: |
161 | case DOC_LINESTRING_OPENED: |
159 | KML_LineStringEnd(doc); // write terminating tag to end linestring. |
162 | KML_LineStringEnd(doc); // write terminating tag to end linestring. |
160 | doc->state = DOC_PLACEMARK_OPENED; |
163 | doc->state = DOC_PLACEMARK_OPENED; |
161 | break; |
- | |
162 | - | ||
163 | case DOC_PLACEMARK_OPENED: // write terminating tag to close placemark. |
- | |
Line -... | Line 164... | ||
- | 164 | break; |
|
- | 165 | ||
- | 166 | case DOC_PLACEMARK_OPENED: // write terminating tag to close placemark. |
|
- | 167 | KML_PlaceMarkClose(doc); |
|
- | 168 | doc->state = DOC_OPENED; |
|
- | 169 | break; |
|
164 | KML_PlaceMarkClose(doc); |
170 | |
165 | doc->state = DOC_OPENED; |
171 | case DOC_OPENED: // close the file on the memorycard |
Line 166... | Line 172... | ||
166 | break; |
172 | if(doc->file != NULL) |
167 | 173 | { |
|
168 | case DOC_OPENED: // close the file on the memorycard |
174 | fwrite_((void*)KML_DOCUMENT_FOOTER, sizeof(KML_DOCUMENT_FOOTER)-1,1,doc->file); // write the KML- footer to the document. |
169 | if(doc->file != NULL) |
175 | fclose_(doc->file); |
170 | { |
- | |
171 | fwrite_(KML_DOCUMENT_FOOTER, sizeof(KML_DOCUMENT_FOOTER)-1,1,doc->file); // write the KML- footer to the document. |
176 | retvalue = 1; |
- | 177 | } |
|
172 | fclose_(doc->file); |
178 | doc->state = DOC_CLOSED; |
173 | retvalue = 1; |
179 | break; |
Line 174... | Line 180... | ||
174 | } |
180 | |
175 | doc->state = DOC_CLOSED; |
181 | default: |
Line 197... | Line 203... | ||
197 | 203 | ||
198 | if(doc->file != NULL) |
204 | if(doc->file != NULL) |
199 | { |
205 | { |
200 | doc->state = DOC_PLACEMARK_OPENED; |
206 | doc->state = DOC_PLACEMARK_OPENED; |
201 | retvalue = 1; |
207 | retvalue = 1; |
202 | fwrite_(KML_PLACEMARK_HEADER, sizeof(KML_PLACEMARK_HEADER)-1,1,doc->file); |
208 | fwrite_((void*)KML_PLACEMARK_HEADER, sizeof(KML_PLACEMARK_HEADER)-1,1,doc->file); |
203 | } |
209 | } |
204 | 210 | ||
205 | return(retvalue); |
211 | return(retvalue); |
Line 206... | Line 212... | ||
206 | } |
212 | } |
207 | 213 | ||
208 | //________________________________________________________________________________________________________________________________________ |
214 | //________________________________________________________________________________________________________________________________________ |
209 | // Funtion: u8 PlaceMarkClose(KML_PlaceMark_t *place, File *file); |
215 | // Function: u8 PlaceMarkClose(KML_PlaceMark_t *place, File *file); |
210 | // |
- | |
211 | // Description: This function ends the placemark opened before. |
216 | // |
- | 217 | // Description: This function ends the placemark opened before. |
|
212 | // |
218 | // |
213 | // |
219 | // |
Line 214... | Line 220... | ||
214 | // Returnvalue: none |
220 | // Returnvalue: 1' if the PlaceMark could be closed |
215 | //________________________________________________________________________________________________________________________________________ |
221 | //________________________________________________________________________________________________________________________________________ |
Line 221... | Line 227... | ||
221 | 227 | ||
222 | if(doc->state == DOC_PLACEMARK_OPENED) |
228 | if(doc->state == DOC_PLACEMARK_OPENED) |
223 | { |
229 | { |
224 | if(doc->file != NULL) |
230 | if(doc->file != NULL) |
225 | { |
231 | { |
226 | doc->state =DOC_OPENED; |
232 | doc->state = DOC_OPENED; |
227 | fwrite_(KML_PLACEMARK_FOOTER, sizeof(KML_PLACEMARK_FOOTER)-1,1,doc->file); |
233 | fwrite_((void*)KML_PLACEMARK_FOOTER, sizeof(KML_PLACEMARK_FOOTER)-1,1,doc->file); |
228 | retvalue = 1; |
234 | retvalue = 1; |
229 | } |
235 | } |
230 | } |
236 | } |
231 | 237 | ||
232 | return(retvalue); |
238 | return(retvalue); |
Line 233... | Line 239... | ||
233 | } |
239 | } |
234 | 240 | ||
235 | //________________________________________________________________________________________________________________________________________ |
241 | //________________________________________________________________________________________________________________________________________ |
236 | // Funtion: u8 LineStringBegin(KML_Document_t *doc); |
242 | // Function: u8 LineStringBegin(KML_Document_t *doc); |
237 | // |
- | |
238 | // Description: This function ends the placemark opened before. |
243 | // |
- | 244 | // Description: This function ends the placemark opened before. |
|
239 | // |
245 | // |
240 | // |
246 | // |
Line 241... | Line 247... | ||
241 | // Returnvalue: none |
247 | // Returnvalue: '1' if the LineString could be started |
242 | //________________________________________________________________________________________________________________________________________ |
248 | //________________________________________________________________________________________________________________________________________ |
Line 243... | Line 249... | ||
243 | 249 | ||
244 | u8 KML_LineStringBegin(KML_Document_t *doc) |
250 | u8 KML_LineStringBegin(KML_Document_t *doc) |
245 | { |
251 | { |
246 | 252 | ||
247 | u8 retvalue = 0; |
253 | u8 retvalue = 0; |
248 | 254 | ||
249 | if(doc->file != NULL) |
255 | if(doc->file != NULL) |
250 | { |
256 | { |
Line 251... | Line 257... | ||
251 | doc->state = DOC_LINESTRING_OPENED; |
257 | doc->state = DOC_LINESTRING_OPENED; |
252 | fwrite_(KML_LINESTRING_HEADER, sizeof(KML_LINESTRING_HEADER)-1,1,doc->file); |
258 | fwrite_((void*)KML_LINESTRING_HEADER, sizeof(KML_LINESTRING_HEADER)-1,1,doc->file); |
Line 253... | Line 259... | ||
253 | retvalue = 1; |
259 | retvalue = 1; |
254 | } |
260 | } |
255 | 261 | ||
256 | return(retvalue); |
262 | return(retvalue); |
257 | } |
- | |
258 | 263 | } |
|
- | 264 | ||
259 | //________________________________________________________________________________________________________________________________________ |
265 | //________________________________________________________________________________________________________________________________________ |
260 | // Funtion: u8 LineStringEnd(KML_Document_t *doc) |
266 | // Function: u8 LineStringEnd(KML_Document_t *doc) |
Line 261... | Line 267... | ||
261 | // |
267 | // |
262 | // Description: This function ends the placemark opened before. |
268 | // Description: This function ends the placemark opened before. |
Line 263... | Line 269... | ||
263 | // |
269 | // |
264 | // |
270 | // |
265 | // Returnvalue: none |
271 | // Returnvalue: '1' if the LineString could be terminated |
266 | //________________________________________________________________________________________________________________________________________ |
272 | //________________________________________________________________________________________________________________________________________ |
267 | 273 | ||
268 | u8 KML_LineStringEnd(KML_Document_t *doc) |
274 | u8 KML_LineStringEnd(KML_Document_t *doc) |
269 | { |
275 | { |
270 | 276 | ||
271 | u8 retvalue = 0; |
277 | u8 retvalue = 0; |
Line 272... | Line 278... | ||
272 | 278 | ||
273 | if(doc->state == DOC_LINESTRING_OPENED); |
279 | if(doc->state == DOC_LINESTRING_OPENED); |
Line 274... | Line 280... | ||
274 | if(doc->file != NULL) |
280 | if(doc->file != NULL) |
275 | { |
281 | { |
276 | doc->state = DOC_PLACEMARK_OPENED; |
282 | doc->state = DOC_PLACEMARK_OPENED; |
277 | fwrite_(KML_LINESTRING_FOOTER, sizeof(KML_LINESTRING_FOOTER)-1,1,doc->file); |
283 | fwrite_((void*)KML_LINESTRING_FOOTER, sizeof(KML_LINESTRING_FOOTER)-1,1,doc->file); |
278 | retvalue = 1; |
- | |
279 | } |
284 | retvalue = 1; |
- | 285 | } |
|
280 | 286 | ||
281 | return(retvalue); |
287 | return(retvalue); |
Line 282... | Line 288... | ||
282 | } |
288 | } |
283 | 289 | ||
Line 284... | Line 290... | ||
284 | //________________________________________________________________________________________________________________________________________ |
290 | //________________________________________________________________________________________________________________________________________ |
285 | // Funtion: u8 LineStringAddPoint(struct str_GPSPosition, KML_Document_t *doc) |
291 | // Function: u8 LineStringAddPoint(gps_data_t, KML_Document_t *doc) |
- | 292 | // |
|
286 | // |
293 | // Description: This function adds a point to the specified document. |
287 | // Description: This function adds a point to the specified document. |
294 | // |
- | 295 | // |
|
- | 296 | // Returnvalue: '1' if a ppoint was added could be started |
|
288 | // |
297 | //________________________________________________________________________________________________________________________________________ |
289 | // |
298 | |
290 | // Returnvalue: none |
299 | u8 KML_LineStringAddPoint(GPS_Pos_t * pGPS_Position ,KML_Document_t *doc) |
- | 300 | { |
|
- | 301 | ||
- | 302 | u8 retvalue = 0; |
|
- | 303 | s8 string[50]; |
|
- | 304 | s32 rel_altitude = 0; |
|
- | 305 | ||
- | 306 | if(doc == NULL || pGPS_Position == NULL) return(0); |
|
- | 307 | ||
- | 308 | if((pGPS_Position->Status != INVALID) && (GPS_HomePosition.Status != INVALID)) |
|
- | 309 | { |
|
- | 310 | if(doc->state == DOC_LINESTRING_OPENED) |
|
- | 311 | { |
|
- | 312 | if(doc->file != NULL) |
|
291 | //________________________________________________________________________________________________________________________________________ |
313 | { |
- | 314 | s32 i1, i2; |
|
- | 315 | i1 = pGPS_Position->Longitude/10000000L; |
|
- | 316 | i2 = abs(pGPS_Position->Longitude%10000000L); |
|
292 | 317 | sprintf(string,"\r\n%ld.%07ld,",i1, i2); |
|
293 | u8 KML_LineStringAddPoint(struct str_gps_nav_data gps_data ,KML_Document_t *doc) |
318 | fputs_(string, doc->file); |
- | 319 | i1 = pGPS_Position->Latitude/10000000L; |
|
294 | { |
320 | i2 = abs(pGPS_Position->Latitude%10000000L); |
295 | 321 | sprintf(string," %ld.%07ld,",i1, i2); |
|
Line 296... | Line 322... | ||
296 | u8 retvalue = 0; |
322 | fputs_(string, doc->file); |
297 | s8 string[50]; |
323 | // calculate relative altitude with respect to the altitude of the home position |
Line 298... | Line 324... | ||
298 | 324 | rel_altitude = pGPS_Position->Altitude - GPS_HomePosition.Altitude; |
|
299 | if(doc->state == DOC_LINESTRING_OPENED) |
325 | if(rel_altitude < 0) rel_altitude = 0; // avoid negative altitudes in log |
300 | { |
326 | i1 = rel_altitude/1000L; |
301 | if(doc->file != NULL) |
327 | i2 = abs(rel_altitude%1000L); |
302 | { |
- | |
303 | sprintf(string,"\r\n%d.%d,%d.%d,%d.0",(gps_data.Longitude/10000000),(gps_data.Longitude%10000000),(gps_data.Latitude/10000000),(gps_data.Latitude%10000000),0); |
328 | sprintf(string," %ld.%03ld",i1, i2); |
- | 329 | fputs_(string, doc->file); |
|
304 | fputs_(doc->file,string); |
330 | retvalue = 1; |
305 | retvalue = 1; |
331 | } |
Line 306... | Line 332... | ||
306 | } |
332 | } |
307 | } |
333 | } |
- | 334 | ||
308 | 335 | return(retvalue); |
|
309 | return(retvalue); |
336 | } |
310 | } |
337 | |
311 | 338 | //________________________________________________________________________________________________________________________________________ |
|
312 | //________________________________________________________________________________________________________________________________________ |
339 | // Function: u8 KML_LoggGPSCoordinates(gps_data_t *, KML_Document_t *) |
313 | // Funtion: u8 KML_LoggGPSCoordinates(struct str_gps_nav_data, KML_Document_t *) |
340 | // |
314 | // |
341 | // Description: This function opens adds gpscoordinates to an KML-Document. The document will be opened, if not already done |
- | 342 | // |
|
315 | // Description: This function opens adds gpscoordinates to an KML-Document. The document will be opened, if not already done |
343 | // |
316 | // |
344 | // Returnvalue: '1' if an gps coordinate was logged |
317 | // |
345 | //________________________________________________________________________________________________________________________________________ |
318 | // Returnvalue: none |
346 | |
Line 319... | Line 347... | ||
319 | //________________________________________________________________________________________________________________________________________ |
347 | u8 KML_LoggGPSCoordinates(GPS_Pos_t* pGPS_Position, KML_Document_t *doc) |
320 | 348 | { |
|
- | 349 | u8 retval = 0; |
|
321 | u8 KML_LoggGPSCoordinates(struct str_gps_nav_data gps_data, KML_Document_t *doc) |
350 | while(doc->state != DOC_LINESTRING_OPENED) // automatic create document with default filename on the card. |
322 | { |
351 | { |
323 | while(doc->state != DOC_LINESTRING_OPENED) // automatic create document with default filename on the card. |
352 | switch(doc->state) |
324 | { |
353 | { |
Line 325... | Line 354... | ||
325 | switch(doc->state) |
354 | case DOC_CLOSED: // document hasn't been opened yet therefore it will be initialized automatically |
326 | { |
355 | KML_DocumentInit(doc); // initialize the document to default values |
- | 356 | retval = KML_DocumentOpen("default.kml",doc); // open the kml-document with a standardname. |
|
327 | case DOC_CLOSED: // document hasn't been opened yet therefore it will be initialized automatically |
357 | if(retval) |
328 | KML_DocumentInit(doc); // initialize the document to default values |
358 | { |
329 | if(KML_DocumentOpen("default.kml",doc)) // open the kml-document with a standardname. |
359 | doc->state = DOC_OPENED; |
330 | { |
360 | } |
Line -... | Line 361... | ||
- | 361 | break; |
|
- | 362 | ||
- | 363 | case DOC_OPENED: // if a document has been opened before but no placemark exists: |
|
- | 364 | retval = KML_PlaceMarkOpen("MIKROKOPTER",doc); |
|
331 | doc->state = DOC_OPENED; |
365 | if(retval) |
- | 366 | { |
|
332 | } |
367 | doc->state = DOC_PLACEMARK_OPENED; // add a placemark to the document. |
Line 333... | Line 368... | ||
333 | break; |
368 | } |
334 | 369 | break; |
|
335 | case DOC_OPENED: // if a document has been opened before but no placemark exists: |
370 | |
336 | if(KML_PlaceMarkOpen("MIKROKOPTER",doc)) |
371 | case DOC_PLACEMARK_OPENED: // add linestring to the placemark |
- | 372 | retval = KML_LineStringBegin(doc); |
|
337 | { |
373 | if(retval) |