Skip to content

Commit

Permalink
Merge #51167
Browse files Browse the repository at this point in the history
51167: geoprojbase: add more NAD83-related SRIDs r=sumeerbhola a=otan

These SRIDs are used in django ORM tests or the PostGIS tutorial.

Also change the format to be consistent between runs, using the full
string output as well.

Release note: None

Co-authored-by: Oliver Tan <[email protected]>
  • Loading branch information
craig[bot] and otan committed Jul 9, 2020
2 parents 492cde2 + e868015 commit 47ef907
Show file tree
Hide file tree
Showing 2 changed files with 2,869 additions and 326 deletions.
30 changes: 19 additions & 11 deletions pkg/cmd/generate-spatial-ref-sys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"os"
"os/exec"
"sort"
"strconv"
"strings"
"text/template"

Expand Down Expand Up @@ -61,22 +62,29 @@ type templateVars struct {
Spheroids []spheroid
}

type projectionBounds struct {
MinX string
MaxX string
MinY string
MaxY string
}

type projection struct {
SRID string
AuthName string
AuthSRID string
SRText string
Proj4Text string
Bounds *geoprojbase.Bounds
Bounds *projectionBounds

IsLatLng bool
SpheroidVarName string
}

type spheroid struct {
VarName string
MajorAxis float64
Flattening float64
MajorAxis string
Flattening string
}

func main() {
Expand Down Expand Up @@ -133,16 +141,16 @@ func getTemplateVars() templateVars {
spheroids,
spheroid{
VarName: spheroidVarName,
MajorAxis: s.Radius,
Flattening: s.Flattening,
MajorAxis: strconv.FormatFloat(s.Radius, 'f', -1, 64),
Flattening: strconv.FormatFloat(s.Flattening, 'f', -1, 64),
},
)
counter++
} else {
spheroidVarName = fmt.Sprintf(`spheroid%d`, foundCounter)
}

var bounds *geoprojbase.Bounds
var bounds *projectionBounds
if record[1] == "EPSG" {
var results struct {
Results []struct {
Expand Down Expand Up @@ -197,11 +205,11 @@ func getTemplateVars() templateVars {
sort.Slice(yCoords, func(i, j int) bool {
return yCoords[i] < yCoords[j]
})
bounds = &geoprojbase.Bounds{
MinX: xCoords[0],
MaxX: xCoords[3],
MinY: yCoords[0],
MaxY: yCoords[3],
bounds = &projectionBounds{
MinX: strconv.FormatFloat(xCoords[0], 'f', -1, 64),
MaxX: strconv.FormatFloat(xCoords[3], 'f', -1, 64),
MinY: strconv.FormatFloat(yCoords[0], 'f', -1, 64),
MaxY: strconv.FormatFloat(yCoords[3], 'f', -1, 64),
}
}

Expand Down
Loading

0 comments on commit 47ef907

Please sign in to comment.