126 |
*/ |
*/ |
127 |
|
|
128 |
|
|
129 |
|
final String STYLE_GREEN = "green"; |
130 |
|
final String STYLE_YELLOW = "yellow"; |
131 |
|
final String STYLE_RED = "red"; |
132 |
|
|
133 |
|
String oldstyle = null; |
|
|
|
|
|
|
134 |
Date now = new Date(); |
Date now = new Date(); |
135 |
for(RequestPosition current : list) { |
for(RequestPosition current : list) { |
136 |
|
|
138 |
long timediff = now.getTime() - current.time.getTime(); |
long timediff = now.getTime() - current.time.getTime(); |
139 |
|
|
140 |
if ( timediff < (3*60*60*1000) ) { |
if ( timediff < (3*60*60*1000) ) { |
141 |
style = "#red"; |
style = STYLE_RED; |
142 |
} else if ( timediff < (24*60*60*1000)) { |
} else if ( timediff < (24*60*60*1000)) { |
143 |
style = "#yellow"; |
style = STYLE_YELLOW; |
144 |
} else { |
} else { |
145 |
style = "#green"; |
style = STYLE_GREEN; |
146 |
|
} |
147 |
|
|
148 |
|
if ( !style.equals(oldstyle) ) { |
149 |
|
if (oldstyle != null) |
150 |
|
sb.append( "</Folder>\n"); |
151 |
|
sb.append( "<Folder>\n"); |
152 |
|
sb.append( " <name>" ).append(style).append("</name>\n"); |
153 |
|
|
154 |
|
oldstyle = style; |
155 |
} |
} |
156 |
|
|
157 |
sb.append( " <Placemark>\n" ); |
sb.append( " <Placemark>\n" ); |
158 |
sb.append( " <styleUrl>" + style + "</styleUrl>\n" ); |
sb.append( " <styleUrl>#" + style + "</styleUrl>\n" ); |
159 |
sb.append( " <description>IP=" + current.ip + " Time=" + current.time + "</description>\n" ); |
sb.append( " <description>IP=" + current.ip + " Time=" + current.time + "</description>\n" ); |
160 |
sb.append( " <Point><coordinates>" + current.lng + "," + current.lat + ",0</coordinates></Point>\n" ); |
sb.append( " <Point><coordinates>" + current.lng + "," + current.lat + ",0</coordinates></Point>\n" ); |
161 |
sb.append( " </Placemark>\n" ); |
sb.append( " </Placemark>\n" ); |
162 |
} |
} |
163 |
|
sb.append( "</Folder>\n" ); |
164 |
sb.append( "</Document>\n" ); |
sb.append( "</Document>\n" ); |
165 |
sb.append( "</kml>\n" ); |
sb.append( "</kml>\n" ); |
166 |
|
|
167 |
return sb.toString(); |
return sb.toString(); |