-
Notifications
You must be signed in to change notification settings - Fork 4
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
VDYP-206 FIPStart output to VRIAdjust input format #26
Changes from 6 commits
bbb7171
45e786d
5fc6ab6
debd644
8ee955d
e265d03
e27fd55
246ae4c
af257b2
d20b390
d2afaa0
c4ad414
f24e93d
ebb1080
844e3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ca.bc.gov.nrs.vdyp.common; | ||
|
||
public class ControlKeys { | ||
|
||
private ControlKeys() { | ||
} | ||
|
||
public static final String VDYP_POLYGON = "VDYP_POLYGON"; | ||
public static final String VDYP_LAYER_BY_SPECIES = "VDYP_LAYER_BY_SPECIES"; | ||
public static final String VDYP_LAYER_BY_SP0_BY_UTIL = "VDYP_LAYER_BY_SP0_BY_UTIL"; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ca.bc.gov.nrs.vdyp.common_calculators; | ||
|
||
import static ca.bc.gov.nrs.vdyp.math.FloatMath.sqrt; | ||
|
||
/* | ||
* Converts between trees per hectare and quad mean diameter given a base area | ||
*/ | ||
public class BaseAreaTreeDensityDiameter { | ||
|
||
private BaseAreaTreeDensityDiameter() { | ||
} | ||
|
||
public static final float PI_40K = 0.78539816E-04f; | ||
|
||
// FT_BD | ||
public static float treesPerHectare(float baseArea, float quadraticMeanDiameter) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should adopt a naming convention wherein units are always suffixed to variable names. In this case, "baseArea" is a number, but what are the units? It's apparent that they're hectares but this should be made explicit. For time, I always use _ms = milliseconds, _s = seconds, and _m, _h, _d, _w, _y. For area, I suggest _h for hectares. I'm not sure what other ones are used in the system. Suggestions? |
||
if (baseArea != 0) { | ||
return baseArea / PI_40K / (quadraticMeanDiameter * quadraticMeanDiameter); | ||
} | ||
return 0f; | ||
} | ||
|
||
// FD_BT | ||
public static float quadMeanDiameter(float baseArea, float treesPerHectare) { | ||
if (baseArea > 1e6f || treesPerHectare > 1e6f || Float.isNaN(baseArea) || Float.isNaN(treesPerHectare)) { | ||
return 0f; | ||
} else if (baseArea > 0f && treesPerHectare > 0f) { | ||
return sqrt(baseArea / treesPerHectare / PI_40K); | ||
} | ||
return 0f; | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
package ca.bc.gov.nrs.vdyp.io; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
public class FileSystemFileResolver implements FileResolver { | ||
|
||
@Override | ||
public InputStream resolve(String filename) throws IOException { | ||
public InputStream resolveForInput(String filename) throws IOException { | ||
return new FileInputStream(filename); | ||
} | ||
|
||
@Override | ||
public OutputStream resolveForOutput(String filename) throws IOException { | ||
return new FileOutputStream(filename); | ||
} | ||
|
||
@Override | ||
public String toString(String filename) throws IOException { | ||
return String.format("file:%s", filename); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these a specific kind of control key? If so, perhaps rename the class. Also, wouldn't this be better as an enumeration?