Select to view content in your preferred language

Drawing a Polygon, don't works correctly.

721
1
07-26-2013 06:54 AM
JUANSANTOS2
New Contributor
Hi, I'm working in a system that has a fault when drawing a polygon, using an Excel file with coordinates, it must draw a polygon in an area of �??�??Mexico, AT MY COMPUTER running the program on Localhost shown as well, in the right location, Annex image:
[ATTACH=CONFIG]26247[/ATTACH]

* but in server production (http://www.cartografia.economia.gob.mx/cartografia/ #) or AT ANOTHER COMPUTER Localhost executing, do not display properly, it shows wrong, it's not a polygon, annex image:
[ATTACH=CONFIG]26246[/ATTACH]

This is de Excel File:
[ATTACH=CONFIG]26248[/ATTACH]


I doubt it's a code problem, could it be a configuration issue on the server?? Or some dependencies??. On my computer it works perfectly.

The computers for local testing, has:
Glassfish 3
NetBeans 7.3.1
Ubuntu 11
One works well and not in another.
Thanks very much.

My apologies for my english.
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: santos.r09

This is the App.xtend:
package mx.com.flint.flintstack

import flexjson.JSONSerializer
import java.io.*; 
import java.net.*;
import java.text.DecimalFormat
import java.util.Calendar
import java.util.Date
import java.util.Scanner;
import mx.com.flint.flintstack.controller.*
import mx.gob.sfp.model.*
import org.apache.commons.fileupload.FileItem
import org.apache.commons.fileupload.FileItemFactory
import org.apache.commons.fileupload.FileUploadException
import org.apache.commons.fileupload.disk.DiskFileItemFactory
import org.apache.commons.fileupload.servlet.ServletFileUpload
import org.apache.poi.hssf.usermodel.*
import org.apache.shiro.SecurityUtils
import spark.Request
import spark.Response
import spark.servlet.SparkApplication
import static extension mx.com.flint.flintstack.Util.*
import static spark.Spark.*
import sun.misc.BASE64Decoder;

class App implements SparkApplication {
    def static geometryFromInputStream(InputStream inputStream){
        val frm = new DecimalFormat("#.000000")
        val frm2 = new DecimalFormat("##")
        var s=""
        val wb = new HSSFWorkbook(inputStream)
        val sheet = wb.getSheetAt(0)
        var renglon=3
        var row = sheet.getRow(2)
        var x = row.getCell(8).numericCellValue
        var y = row.getCell(9).numericCellValue
        var wkid= row.getCell(10).numericCellValue
        s = s + frm.format(x) + "%2C" + frm.format(y) 
        while((row = sheet.getRow(renglon))!=null && !row.getCell(3).toString().trim().isEmpty())
        {
            var direccion = row.getCell(3).toString()
            var a = switch direccion{
                case "SE": -1
                case "NW": -1
                default: 1  
                }
            var b = switch direccion{
                case "S":  180
                case "SW": 180
                case "SE": 180
                case "W":  -90
                case "E":  90
                default:   0
                }
            var grados = row.getCell(4).numericCellValue + (row.getCell(5).numericCellValue/60) + (row.getCell(6).numericCellValue/3600)
            var gradosDireccion = (grados*a)+b
            var radianes = (gradosDireccion * Math::PI)/180
            var dX = row.getCell(7).numericCellValue*Math::sin(radianes)
            var dY = row.getCell(7).numericCellValue*Math::cos(radianes)
            x = x + dX
            y = y + dY
            s = s + "," + frm.format(x) + "%2C" + frm.format(y) 
            renglon = renglon + 1
            }
        var r=""
        val strUrl="http://200.77.231.25/ArcGIS/rest/services/Geometry/GeometryServer/project?geometries="+s+"&inSR=269"+frm2.format(wkid)+"&outSR=102100&f=json"
        val url = new URL(strUrl) 
        val i = new Scanner(url.openStream())
        while (i.hasNextLine()) {r = r+i.nextLine()} 
        r}

    override init() {    
        before(new NoCacheFilter())
        
        get(FlintRoute::getRoute
            ("/logout", 
             [Request req, Response response |
              response.redirect("/")
              null]))


        get(FlintRoute::getRoute
            ("/version", [Request req, Response response | "r01"]))

        get(FlintRoute::getRoute
            ("/from_file", 
             [Request req, Response response |
              geometryFromInputStream(
                        new URL(new String((new BASE64Decoder).
                                           decodeBuffer(req.S("file")))).
                        openStream())
              ]))

        post(FlintRoute::getRoute
             ("/xls2webmercator", 
              [Request req, Response response |
               response.type("text/html")
               val factory = new DiskFileItemFactory()
               val upload = new ServletFileUpload(factory)
               upload.parseRequest(req.raw()).map
               [FileItem fi  | geometryFromInputStream(fi.inputStream)].last()
               ]))
        }
    }
0 Kudos