Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nshmp-haz
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Seismic Hazard Model Project
nshmp-haz
Commits
1f9713e3
Commit
1f9713e3
authored
9 years ago
by
Powers, Peter M.
Browse files
Options
Downloads
Patches
Plain Diff
added bounds() to region; removed min/max lat/lon methods and refactored
parent
bb755fb6
No related branches found
No related tags found
1 merge request
!96
Bounds addition to location based objects
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/org/opensha2/geo/GriddedRegion.java
+10
-7
10 additions, 7 deletions
src/org/opensha2/geo/GriddedRegion.java
src/org/opensha2/geo/Region.java
+12
-31
12 additions, 31 deletions
src/org/opensha2/geo/Region.java
with
22 additions
and
38 deletions
src/org/opensha2/geo/GriddedRegion.java
+
10
−
7
View file @
1f9713e3
...
@@ -471,9 +471,10 @@ public class GriddedRegion extends Region implements Iterable<Location> {
...
@@ -471,9 +471,10 @@ public class GriddedRegion extends Region implements Iterable<Location> {
* Locations would coincide with grid nodes.
* Locations would coincide with grid nodes.
*/
*/
private
void
setAnchor
(
Location
anchor
)
{
private
void
setAnchor
(
Location
anchor
)
{
if
(
anchor
==
null
)
anchor
=
Location
.
create
(
getMinLat
(),
getMinLon
());
Bounds
bounds
=
bounds
();
double
lat
=
computeAnchor
(
getMinLat
(),
anchor
.
lat
(),
latSpacing
);
if
(
anchor
==
null
)
anchor
=
Location
.
create
(
bounds
.
min
().
lat
(),
bounds
.
min
().
lon
());
double
lon
=
computeAnchor
(
getMinLon
(),
anchor
.
lon
(),
lonSpacing
);
double
lat
=
computeAnchor
(
bounds
.
min
().
lat
(),
anchor
.
lat
(),
latSpacing
);
double
lon
=
computeAnchor
(
bounds
.
min
().
lon
(),
anchor
.
lon
(),
lonSpacing
);
this
.
anchor
=
Location
.
create
(
lat
,
lon
);
this
.
anchor
=
Location
.
create
(
lat
,
lon
);
}
}
...
@@ -491,13 +492,15 @@ public class GriddedRegion extends Region implements Iterable<Location> {
...
@@ -491,13 +492,15 @@ public class GriddedRegion extends Region implements Iterable<Location> {
/* Initilize the grid index, node edge, and Location arrays */
/* Initilize the grid index, node edge, and Location arrays */
private
void
initNodes
()
{
private
void
initNodes
()
{
Bounds
bounds
=
bounds
();
// temp node center arrays
// temp node center arrays
double
[]
lonNodes
=
initNodeCenters
(
anchor
.
lon
(),
getMaxL
on
(),
lonSpacing
);
double
[]
lonNodes
=
initNodeCenters
(
anchor
.
lon
(),
bounds
.
max
().
l
on
(),
lonSpacing
);
double
[]
latNodes
=
initNodeCenters
(
anchor
.
lat
(),
getMaxL
at
(),
latSpacing
);
double
[]
latNodes
=
initNodeCenters
(
anchor
.
lat
(),
bounds
.
max
().
l
at
(),
latSpacing
);
// node edge arrays
// node edge arrays
lonEdges
=
initNodeEdges
(
anchor
.
lon
(),
getMaxL
on
(),
lonSpacing
);
lonEdges
=
initNodeEdges
(
anchor
.
lon
(),
bounds
.
max
().
l
on
(),
lonSpacing
);
latEdges
=
initNodeEdges
(
anchor
.
lat
(),
getMaxL
at
(),
latSpacing
);
latEdges
=
initNodeEdges
(
anchor
.
lat
(),
bounds
.
max
().
l
at
(),
latSpacing
);
// range data
// range data
latSize
=
latNodes
.
length
;
latSize
=
latNodes
.
length
;
...
...
This diff is collapsed.
Click to expand it.
src/org/opensha2/geo/Region.java
+
12
−
31
View file @
1f9713e3
...
@@ -283,35 +283,15 @@ public class Region implements Named {
...
@@ -283,35 +283,15 @@ public class Region implements Named {
}
}
/**
/**
* Returns the minimum latitude in this {@code Region}'s border.
* Lazily create the bounds of this region.
* @return the minimum latitude
*/
*/
public
double
getMinLat
()
{
public
Bounds
bounds
()
{
return
area
.
getBounds2D
().
getMinY
();
Rectangle2D
bounds
=
area
.
getBounds2D
();
}
return
new
Bounds
(
bounds
.
getMinY
(),
/**
bounds
.
getMinX
(),
* Returns the maximum latitude in this {@code Region}'s border.
bounds
.
getMaxY
(),
* @return the maximum latitude
bounds
.
getMaxX
());
*/
public
double
getMaxLat
()
{
return
area
.
getBounds2D
().
getMaxY
();
}
/**
* Returns the minimum longitude in this {@code Region}'s border.
* @return the minimum longitude
*/
public
double
getMinLon
()
{
return
area
.
getBounds2D
().
getMinX
();
}
/**
* Returns the maximum longitude in this {@code Region}'s border.
* @return the maximum longitude
*/
public
double
getMaxLon
()
{
return
area
.
getBounds2D
().
getMaxX
();
}
}
/**
/**
...
@@ -343,9 +323,10 @@ public class Region implements Named {
...
@@ -343,9 +323,10 @@ public class Region implements Named {
}
}
@Override
public
String
toString
()
{
@Override
public
String
toString
()
{
String
str
=
"Region\n"
+
"\tMinLat: "
+
this
.
getMinLat
()
+
"\n"
+
"\tMinLon: "
+
Bounds
b
=
bounds
();
this
.
getMinLon
()
+
"\n"
+
"\tMaxLat: "
+
this
.
getMaxLat
()
+
"\n"
+
"\tMaxLon: "
+
String
str
=
"Region\n"
+
"\tMinLat: "
+
b
.
min
().
lat
()
+
"\n"
+
"\tMinLon: "
+
this
.
getMaxLon
();
b
.
min
().
lon
()
+
"\n"
+
"\tMaxLat: "
+
b
.
max
().
lat
()
+
"\n"
+
"\tMaxLon: "
+
b
.
max
().
lon
();
return
str
;
return
str
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment