Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic ZFactor for slope calculation #3014

Merged

Conversation

jbouffard
Copy link
Contributor

@jbouffard jbouffard commented Jul 8, 2019

Overview

This PR adds the ZFactor class as a way of producing the correct zFactor when calculating slope. Before, the zFactor had a default value of 1. However, this doesn't make sense, as the zFactor needs to be calculated on a per-tile bases. The ZFactor class will help by deriving the appropriate ZFactor for each tile depending on its spatial position.

Checklist

  • docs/CHANGELOG.rst updated, if necessary
  • New user API has useful Scaladoc strings
  • Unit tests added for bug-fix or new feature

Closes #2548

Copy link
Member

@pomadchin pomadchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice ZFactor port! Some code style questions remaining and there are no headers generated for new files. See https://github.com/sbt/sbt-header#creating-headers

@jbouffard
Copy link
Contributor Author

@pomadchin Thanks! I should've resolved the issues you pointed out. Also, thanks for reminding me about the headers. I knew I forgot something...

Copy link
Contributor

@echeipesh echeipesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of comments about naming. I feel now that this code is being lifted from geopyspark-backend where there was no user interaction its important to reconsider the naming decisions since this is going to be the front and center API for GT scala.

unit match {
case Feet =>
ZFactorCalculator((lat: Double) => 1 / (LAT_LNG_FEET_AT_EQUATOR * math.cos(math.toRadians(lat))))
case Meters =>
ZFactorCalculator((lat: Double) => 1 / (LAT_LNG_METERS_AT_EQUATOR * math.cos(math.toRadians(lat))))
}

def createZFactorCalculator(mappedLats: Map[Double, Double]): ZFactorCalculator = {
def createCalculator(mappedLats: Map[Double, Double]): ZFactorCalculator = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little pedantic but I still think worth pointing out words like create are generally filler words in function names. Constructors create an object, functions return a value. Unless there is a special significance to the fact that you're getting a new instance, if it has surprisingly high resource requirement for instance, they are unnecessary.

createCalculator is more meaningful as interpolateFromTable - given that interpolation is the critical thing that it does.

createLatLngCalculator is as meaningful and shorter as forLatLng giving you the following full path ZFactorCalculator.forLatLng

@echeipesh
Copy link
Contributor

I'm 👍 on squants after realizing there still isn't a standard Java units library.
Just checked, it needs CQ added: https://github.com/locationtech/geotrellis/blob/master/docs/CQ.rst

jbouffard added 17 commits July 10, 2019 10:44
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
…to use the ZFactorCalculator

Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
…kage object

Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
…thods

Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
@jbouffard jbouffard force-pushed the feature/zfactor-calculator-con branch from 2cf3f86 to 507c783 Compare July 10, 2019 14:45
@jbouffard
Copy link
Contributor Author

Just created the CQ for squants: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=20340#c0

Signed-off-by: Jacob Bouffard <jbouffard@azavea.com>
@echeipesh echeipesh changed the title ZFactorCalculator Add dynamic ZFactor for slope calculation Jul 10, 2019
@echeipesh
Copy link
Contributor

@jbouffard heads up, you attached the artifact jar instead of the source jar on that CQ request.

@pomadchin pomadchin merged commit c6f424d into locationtech:master Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a Method That Calculates ZFactor
3 participants