Jump to content

php2010

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

php2010's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've been digging and I found this. Really wish I understood GIS a little more. :-\
  2. Sounds interesting. If you come up with anything let me know. I appreciate all the help. I'm gonna try some more stuff after work today.
  3. I don't really know what you would call it. Something like how GIS software ""dissolves"" boundaries together. Merging all polygons to form one and eliminate any spaces. Seems very difficult.
  4. Well I've read plenty on this topic but I haven't found something that's really ""stuck out"" to me. Stuff like this and so forth.
  5. What I'm looking to do is analyze an array of coordinates and generate a convex-hull type outline of all independent polygons merged. Convex hull isn't ideal for my situation as I need the outline detailed. From: To: This is how the data is arranged (The keys are just for reference): $array['Group_01']['Polygon_01'] = array('latitude, longitude', 'latitude, longitude', 'latitude, longitude', etc.); $array['Group_01']['Polygon_02'] = array('latitude, longitude', 'latitude, longitude', 'latitude, longitude', etc.); $array['Group_01']['Polygon_03'] = array('latitude, longitude', 'latitude, longitude', 'latitude, longitude', etc.); $array['Group_02']['Polygon_01'] = array('latitude, longitude', 'latitude, longitude', 'latitude, longitude', etc.); $array['Group_02']['Polygon_02'] = array('latitude, longitude', 'latitude, longitude', 'latitude, longitude', etc.); etc. Basically in that scenario I would like to join ALL of the coordinates to form an outline in both 'Group_01' and 'Group_02' based on the polygons in 'Polygon_xx' under that group. Each outline independent of itself. So 'Group_01' would be a union of $array['Group_01']['Polygon_01'], $array['Group_01']['Polygon_02'], and $array['Group_01']['Polygon_03']. Then 'Group_02' would be a union of $array['Group_02']['Polygon_01'] and $array['Group_02']['Polygon_02']. This would output an array of something like $array['Group_01']['Unified'] and $array['Group_02']['Unified'] etc. Is this possible? Any help would be greatly appreciated. Thanks.
  6. I found the solution. This can be removed.
  7. I'm having a bit of trouble converting dates from strings. "171630Z - 181200Z" is what I would like to convert. I want to be able to display more information via date() with strtotime(). The timezone I would prefer is Central. To explain what the string represents: 17 = day (December 17th - today) 1630Z = time in UTC/GMT 18 = day (December 18th - tomorrow) 1200Z = time in UTC/GMT Is there an easy way of doing this or is it impossible with just the day and time in UTC? Thanks. Edit: I would also like to convert "1009 AM CST FRI DEC 17 2010" but that isn't working either. :-\
  8. I've been reading as much as I can but I can't seem to figure this out. I'm confused by arrays, exploding, and organizing the data. && LAT...LON 4151 7448 4160 7438 4164 7427 4161 7424 4159 7414 4162 7413 4162 7410 4159 7405 4159 7396 4145 7399 4149 7393 4150 7385 4121 7385 4103 7450 4108 7451 4119 7438 4135 7471 4140 7475 4150 7475 TIME...MOT...LOC 0838Z 236DEG 47KT 4159 7465 4137 7463 4098 7497 $$ The data I would like to get is between: 'LAT...LON' and 'TIME...MOT'. Is the best way of doing this like below?: preg_match_all('/LAT...LON (.*)\nTIME...MOT/Uism',$data,$results); $SVR = $results[1]; The problem I'm having, I want to explode all of those numbers and convert them over to LAT/LON (xx.xx, -yy.yy) and echo the first lat/lon at the end to complete the "line". While also keeping EACH section separate to it's own line and echo them out like this: Color: 000 000 255 Line: 6,0,"blah" 41.51, -74.48 41.60, -74.38 41.64, -74.27 41.61, -74.24 41.59, -74.14 41.62, -74.13 41.62, -74.10 41.59, -74.05 41.59, -73.96 41.45, -73.99 41.49, -73.93 41.51, -74.48 End: Color: 000 000 255 Line: 6,0,"blah" SECOND SET OF LAT/LON HERE End: Color: 000 000 255 Line: 6,0,"blah" THIRD SET OF LAT/LON HERE End: So on and so forth. After I figure out how to keep everything separate I should be able to figure it out. I'm having some real trouble with the arrays. Here's the current file I've figured out so far: $file = fopen('svr.txt','r'); while($t = fread($file,102465)){ $data .= $t; } fclose($file); preg_match_all('/LAT...LON (.*)\nTIME...MOT/Uism',$data,$results); $SVR = $results[1]; $SVR = preg_replace('/\n/', ' ', $SVR); $SVR = preg_replace('/\s\s+/', ' ', $SVR); unset($data); header("Content-Type: text/plain"); $svrlatlon = array_unique($SVR); $svrwarning1 = $svrlatlon[0]; $svrwarning1 = explode(" ", $svrwarning1); $svrwarning1count = count($svrwarning1); $svrwarning2 = $svrlatlon[1]; $svrwarning2 = explode(" ", $svrwarning2); $svrwarning2count = count($svrwarning2); $svrwarning3 = $svrlatlon[2]; $svrwarning3 = explode(" ", $svrwarning3); $svrwarning3count = count($svrwarning3); $svrwarning4 = $svrlatlon[3]; $svrwarning4 = explode(" ", $svrwarning4); $svrwarning4count = count($svrwarning4); echo "Severe Thunderstorm 1 Lat Lon:\n"; for ($i = 0; $i < $svrwarning1count; $i+= 2) { if ($svrwarning1[$i+1] != null) { echo substr($svrwarning1[$i], -4, 2) . "." . substr($svrwarning1[$i], -2, 2) . ", -" . substr($svrwarning1[$i+1], -4, 2) . "." . substr($svrwarning1[$i+1], -2, 2) . "\n"; } } if ($svrwarning1[0] != null){ echo substr($svrwarning1[0], -4, 2) . "." . substr($svrwarning1[0], -2, 2) . ", -" . substr($svrwarning1[1], -4, 2) . "." . substr($svrwarning1[1], -2, 2) . "\n\n\n"; } echo "Severe Thunderstorm 2 Lat Lon:\n"; for ($i = 0; $i < $svrwarning2count; $i+= 2) { if ($svrwarning2[$i+1] != null) { echo substr($svrwarning2[$i], -4, 2) . "." . substr($svrwarning2[$i], -2, 2) . ", -" . substr($svrwarning2[$i+1], -4, 2) . "." . substr($svrwarning2[$i+1], -2, 2) . "\n"; } } if ($svrwarning2[0] != null){ echo substr($svrwarning2[0], -4, 2) . "." . substr($svrwarning2[0], -2, 2) . ", -" . substr($svrwarning2[1], -4, 2) . "." . substr($svrwarning2[1], -2, 2) . "\n\n\n"; } echo "Severe Thunderstorm 3 Lat Lon:\n"; for ($i = 0; $i < $svrwarning3count; $i+= 2) { if ($svrwarning3[$i+1] != null) { echo substr($svrwarning3[$i], -4, 2) . "." . substr($svrwarning3[$i], -2, 2) . ", -" . substr($svrwarning3[$i+1], -4, 2) . "." . substr($svrwarning3[$i+1], -2, 2) . "\n"; } } if ($svrwarning3[0] != null){ echo substr($svrwarning3[0], -4, 2) . "." . substr($svrwarning3[0], -2, 2) . ", -" . substr($svrwarning3[1], -4, 2) . "." . substr($svrwarning3[1], -2, 2) . "\n\n\n"; } echo "Severe Thunderstorm 4 Lat Lon:\n"; for ($i = 0; $i < $svrwarning4count; $i+= 2) { if ($svrwarning4[$i+1] != null) { echo substr($svrwarning4[$i], -4, 2) . "." . substr($svrwarning4[$i], -2, 2) . ", -" . substr($svrwarning4[$i+1], -4, 2) . "." . substr($svrwarning4[$i+1], -2, 2) . "\n"; } } if ($svrwarning4[0] != null){ echo substr($svrwarning4[0], -4, 2) . "." . substr($svrwarning4[0], -2, 2) . ", -" . substr($svrwarning4[1], -4, 2) . "." . substr($svrwarning4[1], -2, 2) . "\n\n\n"; } If anyone knows how to do this, can you explain it or add comment sections to the code so I can better understand how to achieve this? Thanks.
  9. I got a buddy of mine to recode some things and this is finished.
  10. I have the code for the odd/even but the problem is, it takes the answer from the FIRST STNRY points (for $difference) and uses that same value for the second and so on. So when the first STNRY line is even, it says that the second line is even as well which is not a desirable output. if ($explodedstnry_length & 1) {$difference = 1;} if ($explodedstnry_length & 0) {$difference = 2;} That is the code I'm using before echoing the Line statements. :-\
  11. Alright it looks like I only have one more problem left with this. I need to be able to count how many lat lon points there are for EACH STNRY and make $difference = 2 if it's odd and $difference = 1 if it's even that way I can use $difference to subtract from $explodedstnry_length so it outputs the exact amount of lines I need. Like this: for ($i = 1; $i < $explodedstnry_length - $difference; $i+= 2) { if ($lonstnry[$i+2] != null){ echo "Color: 255 000 000\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i]/10) . ', -' . ($lonstnry[$i]/10) . "\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo "End:\n"; echo "Color: 000 000 255\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo ($latstnry[$i+2]/10) . ', -' . ($lonstnry[$i+2]/10) . "\n"; echo "End:\n";} Is this possible? Edit I didn't notice you had replied sorry. I haven't had any experience at all with functions but I will take it into consideration and play with it a bit. Edit 2: I just tried to run the functions and I get this: <b>Fatal error</b>: Cannot redeclare format_latlong() (previously declared in fronts_fuctions.php:59) in <b>fronts_fuctions.php</b> on line <b>59</b><br />
  12. Ignore this post I just figured it out. I tried to edit but I was too late.
  13. I just ran a test run with the "if ($cur_line !== null) $lines_arr[] = $cur_line;" line added to the bottom and it's still not showing the last stationary line.
  14. I've placed this code at the end and no errors have been reported. I will post back if anything else goes wrong. Thanks a bunch! Thanks for this code! I will def play around with this. What I'm currently doing is this: if (strpos($line, "HIGHS") === 0) { $line = chop($line); $explodedhp = explode(" ", $line); $explodedhp_length = count($explodedhp); for ($i = 1; $i < $explodedhp_length; $i += 2) { $lathp[$i] = substr($explodedhp[$i+1], -7, 3); $lonhp[$i] = substr($explodedhp[$i+1], -4, 4); $lathp2[$i] = substr($explodedhp[$i+1], -7, 3) - 1.5; $lonhp2[$i] = substr($explodedhp[$i+1], -4, 4); echo "Object: ".($lathp[$i]/10).", -".($lonhp[$i]/10)."\nThreshold:999\nColor: 255 100 000\n"; echo "Icon: 0,0, 0, 2, 1, ",$explodedhp[$i]."MB\n"; echo "Text: 0, -30, 1, \"".$explodedhp[$i]."MB\"\nEnd:\n\n"; }echo "\n\n"; } The same basically for Lows except with a different color, etc. The only other somewhat weird problem I'm having is alternating the colors of the stationary front lines. What I would like to do is like have this: lat1,lon1 to lat2,lon2 - RED LINE lat2,lon2 to lat3,lon3 - BLUE LINE On and on until it reaches no more lat lon points. So 4 lat points would make: --- --- --- and an output of something like: Color: 255 000 000 Line: 6,0,"Stationary Front at 9 PM" 31.1, -87.1 30.4, -88.2 End: Color: 000 000 255 Line: 6,0,"Stationary Front at 9 PM" 30.4, -88.2 30.1, -88.9 End: Color: 255 000 000 Line: 6,0,"Stationary Front at 9 PM" 31.1, -87.1 30.4, -88.2 End: I'm currently achieving this but with a few errors below: if (strpos($line, "STNRY") === 0) { $line = chop($line); $explodedstnry = explode(" ", $line); $explodedstnry_length = count($explodedstnry); for ($i = 1; $i < $explodedstnry_length; $i++) { $latstnry[$i] = substr($explodedstnry[$i], -7, 3); $lonstnry[$i] = substr($explodedstnry[$i], -4, 4);} if ($explodedstnry % 2 == 1) {for ($i = 1; $i < $explodedstnry_length - 1; $i+= 2) { if ($lonstnry[$i+2] != null){ echo "Color: 255 000 000\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i]/10) . ', -' . ($lonstnry[$i]/10) . "\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo "End:\n"; echo "Color: 000 000 255\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo ($latstnry[$i+2]/10) . ', -' . ($lonstnry[$i+2]/10) . "\n"; echo "End:\n";} if ($latstnry[$i+2] == null && $lonstnry[$i+1] != null){ echo "Color: 255 000 000\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i]/10) . ', -' . ($lonstnry[$i]/10) . "\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo "End:\n"; }else{ for ($i = 1; $i < $explodedstnry_length - 2; $i+= 2) { if ($lonstnry[$i+2] != null){ echo "Color: 255 000 000\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i]/10) . ', -' . ($lonstnry[$i]/10) . "\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo "End:\n"; echo "Color: 000 000 255\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo ($latstnry[$i+2]/10) . ', -' . ($lonstnry[$i+2]/10) . "\n"; echo "End:\n";} if ($latstnry[$i+2] == null && $lonstnry[$i+1] != null){ echo "Color: 255 000 000\nLine: 6,0,\"Stationary Front at ".$timect."\"\n"; echo ($latstnry[$i]/10) . ', -' . ($lonstnry[$i]/10) . "\n"; echo ($latstnry[$i+1]/10) . ', -' . ($lonstnry[$i+1]/10) . "\n"; echo "End:\n";}} }} }echo "\n\n"; Every now and then there will be more than 1 stationary front and if it's an odd amount of lat/lon points it will connect the ODD stationary front to the following stationary front. I tried to stop this with an if statement of: if ($explodedstnry % 2 == 1) Basically saying IF ODD then "$explodedstnry_length - 1" ELSE "$explodedstnry_length - 2" which makes sense right? The math of this is kind of confusing for me looking at all this code combined together. I don't know if there's an easier way to achieve what I want to do or not but so far this has been a pain and I have to keep changing it to keep it working.
  15. I ran into a little problem. For some reason it isn't catching the last line of the source. Like right now this is the data: CODED SURFACE FRONTAL POSITIONS NWS HYDROMETEOROLOGICAL PREDICTION CENTER CAMP SPRINGS MD 825 PM EST SAT NOV 13 2010 VALID 111400Z HIGHS 1021 3340813 1022 3840775 1033 4291214 1028 5070752 1022 3350963 LOWS 1004 4450907 1002 6481006 998 6591355 1000 6111579 1016 3531047 984 7300598 987 6590579 994 6070493 1003 5391451 COLD 2950919 2830927 2690940 2580948 2480957 2360963 2280969 2190976 OCFNT 4450907 4470903 4480897 4490889 4470881 4450875 4420869 4380865 4310862 COLD 4310862 4230860 4150859 4040860 3890864 3650874 3340890 3120904 2950917 COLD 5570390 5260437 5040484 4930534 4880553 4780574 4660596 4550615 4450632 4400646 4350662 4320675 4300708 4290724 4300743 4300758 WARM 6471004 6430977 6360941 6290920 6210904 6090890 COLD 6461009 6361021 6261036 6161056 6061083 6001111 5981134 5981156 6011184 6111211 WARM 6581351 6531316 6411275 6301247 6111212 STNRY 6581358 6581389 6531419 6441439 6381463 6361484 6331516 6261548 6161570 6111578 COLD 6081577 5961575 5801578 5581592 TROF 5651150 5511133 5291112 5061099 4851092 4531083 TROF 4151241 3991234 3821225 3641214 3471201 3281183 TROF 4061025 3891029 3691036 3531047 3431059 3361075 3341097 TROF 6580581 6880580 7160588 7420610 7610643 7840636 OCFNT 6070495 5950457 5840429 5690405 5580390 TROF 6110506 6300523 6490544 6590570 TROF 6480589 6040572 5760556 5480538 WARM 5331359 5081315 4801288 COLD 5901588 5901588 WARM 5570390 5380369 5250357 5150351 COLD 5331359 5231356 5111363 5011378 4891400 4801417 4691439 OCFNT 5391450 5431427 5421393 5341360 TROF 6861739 6821697 6721653 6601628 6471610 STNRY 4300759 4270782 4200808 4160820 4170829 4180834 4210838 4260842 4290845 4300850 4300854 4310858 4310861 $$ and it's not pulling and and making the "STNRY" line.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.