update
|
@ -6,4 +6,4 @@
|
|||
* github.com/nferruzzi/gormGIS
|
||||
|
||||
|
||||
http://localhost:9000/toilet?BBOX=177000%2C437000%2C219000%2C466000
|
||||
http://localhost:9000/toilet?BBOX=177000%2C437000%2C219000%2C466000&SRS=EPSG:2097&WIDTH=1024&HEIGHT=768
|
||||
|
|
|
@ -25,31 +25,44 @@ func (c GoMap) Index() revel.Result {
|
|||
//look at the Custom Result More.
|
||||
|
||||
func (c GoMap) Toilet() revel.Result {
|
||||
var bbox string
|
||||
var bbox,srs,widthStr,heightStr string
|
||||
srsNo:=2097
|
||||
c.Params.Bind(&bbox, "BBOX")
|
||||
c.Params.Bind(&srs, "SRS")
|
||||
c.Params.Bind(&widthStr, "WIDTH")
|
||||
c.Params.Bind(&heightStr, "HEIGHT")
|
||||
splited:=strings.Split(srs,"EPSG:")
|
||||
if(len(splited)>1){
|
||||
srsNo,_ = strconv.Atoi(splited[1])
|
||||
}else{
|
||||
srsNo,_ = strconv.Atoi(splited[0])
|
||||
}
|
||||
var bboxSlice = strings.Split(bbox,",");
|
||||
fmt.Println(bbox);
|
||||
var toilets []models.Toilet
|
||||
var toilets []models.Toilet
|
||||
//177000,437000,219000,466000
|
||||
minx,_ := strconv.Atoi(bboxSlice[0])
|
||||
miny,_ := strconv.Atoi(bboxSlice[1])
|
||||
maxx,_ := strconv.Atoi(bboxSlice[2])
|
||||
maxy,_ := strconv.Atoi(bboxSlice[3])
|
||||
Db.Where("geom && ST_MakeEnvelope(?,?,?,?,?)",minx,miny,maxx,maxy,epsg).Find(&toilets);
|
||||
fmt.Println();
|
||||
// minP := models.Point{177000, 437000}
|
||||
// maxP := models.Point{219000, 466000}
|
||||
// bnd := &models.Bounds{models.Rectangle{minP,maxP}}
|
||||
fmt.Println(minx,miny,maxx,maxy);
|
||||
minP := models.Point{minx,miny}
|
||||
maxP := models.Point{maxx,maxy}
|
||||
minx,err := strconv.ParseFloat(bboxSlice[0],64)
|
||||
miny,err := strconv.ParseFloat(bboxSlice[1],64)
|
||||
maxx,err := strconv.ParseFloat(bboxSlice[2],64)
|
||||
maxy,err := strconv.ParseFloat(bboxSlice[3],64)
|
||||
width,err := strconv.Atoi(widthStr)
|
||||
height,err := strconv.Atoi(heightStr)
|
||||
fmt.Println("converted",minx,miny,maxx,maxy,width,height);
|
||||
Db.Where("geom && ST_Transform(ST_MakeEnvelope(?,?,?,?,?),2097)",minx,miny,maxx,maxy,srsNo).Find(&toilets);
|
||||
var contertedBndStr string
|
||||
srsNoStr :=strconv.Itoa(srsNo)
|
||||
rows, err := Db.Model(toilets).First(&contertedBndStr).Select("ST_Transform(ST_MakeEnvelope("+bboxSlice[0]+","+bboxSlice[1]+","+bboxSlice[2]+","+bboxSlice[3]+","+srsNoStr+"),2097))").Rows() // (*sql.Rows, error)
|
||||
defer rows.Close()
|
||||
fmt.Println("converted bounds : ",contertedBndStr);
|
||||
fmt.Println(len(toilets));
|
||||
minP := models.Point{int(minx),int(miny)}
|
||||
maxP := models.Point{int(maxx),int(maxy)}
|
||||
bnd := &models.Bounds{models.Rectangle{minP,maxP}}
|
||||
filename := services.DrawPoint( toilets, bnd, 1024, 768 )
|
||||
fmt.Println(revel.BasePath,filename);
|
||||
filename := services.DrawPoint( toilets, bnd, width,height )
|
||||
fmt.Println(revel.BasePath,filename);
|
||||
file, _ := os.Open(revel.BasePath+"/output/wms/"+filename)
|
||||
// defer file.Close()
|
||||
fileInfo, err:= file.Stat()
|
||||
fmt.Println(fileInfo.Size(), err) //the err is nil
|
||||
fmt.Println(fileInfo,err) //the err is nil
|
||||
// return c.Render(filename)
|
||||
return c.RenderFile(file, revel.Inline )//Not an attachment. But Who disconnect the file.
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"image/color"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"github.com/revel/revel"
|
||||
"github.com/ninjasphere/draw2d/draw2dkit"
|
||||
"github.com/ninjasphere/draw2d/draw2dimg"
|
||||
"github.com/ehrudxo/revel_test1/app/models"
|
||||
|
@ -17,6 +18,7 @@ func PrintPoint(toilets []models.Toilet) {
|
|||
}
|
||||
}
|
||||
func DrawPoint( toilets []models.Toilet, b *models.Bounds, imgWidth int, imgHeight int) string{
|
||||
fmt.Println(imgWidth,imgHeight);
|
||||
filename := strconv.Itoa(b.Min.X) + "_" + strconv.Itoa(b.Min.Y)
|
||||
filename += "_" + strconv.Itoa(b.Max.X) + "_" + strconv.Itoa(b.Max.Y)
|
||||
filename += "_" +strconv.Itoa(imgWidth) + "_" + strconv.Itoa(imgHeight) +".png"
|
||||
|
@ -35,6 +37,6 @@ func DrawPoint( toilets []models.Toilet, b *models.Bounds, imgWidth int, imgHeig
|
|||
gc.FillStroke()
|
||||
}
|
||||
gc.Close()
|
||||
draw2dimg.SaveToPngFile("output/wms/"+filename, dest)
|
||||
draw2dimg.SaveToPngFile(revel.BasePath+"/output/wms/"+filename, dest)
|
||||
return filename
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{{set . "title" "Home"}}
|
||||
{{append . "moreStyles" "css/map.css"}}
|
||||
{{append . "moreScripts" "js/jquery-1.9.1.min.js"}}
|
||||
{{append . "moreScripts" "js/map.js"}}
|
||||
{{template "header.html" .}}
|
||||
|
||||
<header class="hero-unit" style="background-color:#A9F16C">
|
||||
|
@ -20,5 +23,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "footer.html" .}}
|
||||
|
|
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 820 B |
|
@ -0,0 +1,17 @@
|
|||
var map
|
||||
$( document ).ready(function() {
|
||||
console.log( "ready!" );
|
||||
map= L.map('map').setView([37.519459, 126.983113], 13);
|
||||
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
L.tileLayer(osmUrl, {
|
||||
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
|
||||
maxZoom: 18
|
||||
}).addTo(map);
|
||||
var toilet = L.tileLayer.wms("http://localhost:9000/toilet", {
|
||||
layers: 'toilet',
|
||||
format: 'image/png',
|
||||
transparent: true,
|
||||
attribution: "public toilet"
|
||||
});
|
||||
map.addLayer(toilet);
|
||||
});
|