ustroetz/cost_model — pull request #31 by perrygeo (2013-12-14 22:44:16+00:00)
Title: Fix some ZeroDivision errors and Geometry problems

These two commits fix some of the errors we were seeing the forest planner:

* When the total volume per acre is zero (thinning where no haulable timber was produced). The fix was just assume haul cost = 0

Example cost arguments
```
(37.2261390236319, 146.7, 9.428571, u'POLYGON((-13718013.584274 5690391.0703407,-13718012.2797802 5690391.21565105,-13718018.1647716 5690528.51682707,-13718020.9301872 5690537.33767144,-13718020.5944989 5690927.17579635,-13717997.4208254 5690920.28946657,-13717951.4005044 5690897.8814476,-13717908.0196312 5690879.1683337,-13717863.3405645 5690859.2375481,-13717848.0996911 5690854.70825953,-13717807.0613138 5690830.86921968,-13717779.1764477 5690824.24547142,-13717762.2129679 5690805.89769973,-13717741.736409 5690795.23814539,-13717721.3447576 5690787.09871946,-13717688.0546124 5690769.30428066,-13717658.6171682 5690753.9022239,-13717640.3133225 5690733.07677582,-13717614.6862073 5690718.8070318,-13717607.6340289 5690718.34000415,-13717606.9708261 5690080.16308344,-13718009.3300436 5690083.69426681,-13718010.3065797 5690154.25175569,-13718011.5682994 5690245.41373594,-13718013.584274 5690391.0703407))', 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, (-123.237962, 45.443191), 21.524912811, 37.62, (-123.25, 45.61))
```

* When the stand centroid, landing and skid line don't intersect the stand polygon. See image below. The fix was to set yarding distance from the landing to the polygon geometry itself in these cases.
![bad_stand](https://f.cloud.github.com/assets/1151287/1749363/c4ce445c-650e-11e3-836a-36a0e47ece03.png)

Example cost arguments:
```
(7.22182759045996, 307.352941, 39.294118, u'POLYGON((-13726989.498883 5730749.161143,-13727018.162769 5730698.999343,-13726769.484194 5730657.552914,-13726631.200313 5730613.007686,-13726542.819999 5730522.238715,-13726518.933428 5730438.635715,-13726435.330428 5730345.478087,-13726366.181675 5730290.161049,-13726236.101532 5730289.344646,-13726227.9556712 5730294.85504406,-13726289.622343 5730347.866744,-13726449.662371 5730467.299601,-13726528.488056 5730593.898429,-13726624.034342 5730694.222028,-13726989.498883 5730749.161143))', 1.53, 0.82, 29.25, 29.82, 22.59, 489.74, 1.0, 0.38, 0.04, 1, (-123.313987, 45.684241), 7.475714501000001, 17.07, (-123.25, 45.61))
```

Could you double-check the assumptions I've made? If you know of better ways to estimate costs for these cases, let me know.