Java jxmapkit click事件返回不正确的lat long

Java jxmapkit click事件返回不正确的lat long,java,netbeans,openstreetmap,mouseclick-event,Java,Netbeans,Openstreetmap,Mouseclick Event,我使用JXmapkit在一个框架中显示带有openstreetmaps路线点的地图,其中路线点的坐标存储在数据库中。单击某个位置时,应用程序将检查该区域的坐标是否在某个航路点周围的区域内,如果为真,则打开一个内部帧。问题是,单击位置的坐标总是返回错误的示例,正确的坐标(35.9097,14.4259)返回为(85.05012,-179.96198)。我试图添加差异,但它不起作用,因为我无法确定坐标之间的确切差异,因为每次单击同一位置时,坐标总是不同。我是错过了什么还是做错了什么 public s

我使用JXmapkit在一个框架中显示带有openstreetmaps路线点的地图,其中路线点的坐标存储在数据库中。单击某个位置时,应用程序将检查该区域的坐标是否在某个航路点周围的区域内,如果为真,则打开一个内部帧。问题是,单击位置的坐标总是返回错误的示例,正确的坐标(35.9097,14.4259)返回为(85.05012,-179.96198)。我试图添加差异,但它不起作用,因为我无法确定坐标之间的确切差异,因为每次单击同一位置时,坐标总是不同。我是错过了什么还是做错了什么

public static  ArrayList<StopBS> GetBusStopByCoordinates(float x, float y, float radius)
{
    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;
    try
    {
        ArrayList<StopBS> stops = new ArrayList<StopBS>();
        Class.forName("org.sqlite.JDBC");
        connection = DriverManager.getConnection(ConnectionString);
        statement = connection.createStatement(); 
       // Added value
       // x -= 49.1401725;
       // y += 194.4150295;
        float x1 = x - radius;
        float x2 = x + radius;
        float y1 = y - radius;
        float y2 = y + radius;
        String command = "SELECT StopID, StopNumber, Tag, Latitude, Longitude FROM StopTable  WHERE (Latitude BETWEEN %f AND %f) AND (Longitude BETWEEN %f AND %f)" ;
        command = String.format(command, x1,x2,y1,y2);
        resultSet = statement.executeQuery(command);
        while (resultSet.next())
        {
            StopBS newStop = new StopBS();
            newStop.StopID = resultSet.getInt("StopID");
            newStop.StopNumber = resultSet.getInt("StopNumber");
            newStop.Tag = resultSet.getString("Tag");
            newStop.Lat = resultSet.getFloat("Latitude");
            newStop.Long = resultSet.getFloat("Longitude");
            stops.add(newStop);
        }
        return stops;
    }
    catch (Exception e)
    {
        e.printStackTrace();
        return null;
    }
    finally
    {
        try
        {
            resultSet.close();
            statement.close();
            connection.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
mainMap.getMainMap().addMouseListener(new MouseInputAdapter()
{      
        public void mouseClicked(MouseEvent e)
        {
           //Get mouse click position in screen values
            Point point = e.getPoint();
            //get map component
            JXMapViewer map = mainMap.getMainMap();
            //calculate x, y for map as the point is relative to the whole screen
           Rectangle bounds = getBounds();
            int x = (int)(point.getX() - bounds.getX());
            int y = (int)(point.getY() - bounds.getY());

            //Get the lat and long from the x and y mouse position
            Point2D pixelcoord1 = point;

           GeoPosition mappos =   map.getTileFactory().pixelToGeo(pixelcoord1, map.getZoom());
            Point2D QALLA =  map.getTileFactory().geoToPixel(mappos, map.getZoom());

           //check in database for busstops in that area 0.0015F
          ArrayList<StopBS> stops =  DataAccess.GetBusStopByCoordinates((float)mappos.getLatitude(),(float)mappos.getLongitude(), 0.0015F);
        }
    });
}    
public static ArrayList GetBusStopByCoordinates(浮点x、浮点y、浮点半径)
{
连接=空;
Statement=null;
ResultSet ResultSet=null;
尝试
{
ArrayList停止=新建ArrayList();
Class.forName(“org.sqlite.JDBC”);
connection=DriverManager.getConnection(ConnectionString);
statement=connection.createStatement();
//附加值
//x-=49.1401725;
//y+=194.4150295;
浮点x1=x-半径;
浮动x2=x+半径;
浮动y1=y-半径;
浮动y2=y+半径;
String command=“从StopTable WHERE(纬度在%f和%f之间)和(经度在%f和%f之间)中选择StopID、StopNumber、标记、纬度、经度”;
command=String.format(command,x1,x2,y1,y2);
resultSet=statement.executeQuery(命令);
while(resultSet.next())
{
StopBS newStop=新StopBS();
newStop.StopID=resultSet.getInt(“StopID”);
newStop.StopNumber=resultSet.getInt(“StopNumber”);
newStop.Tag=resultSet.getString(“Tag”);
newStop.Lat=resultSet.getFloat(“纬度”);
newStop.Long=resultSet.getFloat(“经度”);
停止。添加(newStop);
}
返回站;
}
捕获(例外e)
{
e、 printStackTrace();
返回null;
}
最后
{
尝试
{
resultSet.close();
语句。close();
connection.close();
}
捕获(例外e)
{
e、 printStackTrace();
}
}
}
mainMap.getMainMap().addMouseListener(新的MouseInputAdapter())
{      
公共无效mouseClicked(MouseEvent e)
{
//获取屏幕值中的鼠标单击位置
Point=e.getPoint();
//获取映射组件
JXMapViewer map=mainMap.getMainMap();
//计算地图的x,y,因为该点相对于整个屏幕
矩形边界=getBounds();
int x=(int)(point.getX()-bounds.getX());
int y=(int)(point.getY()-bounds.getY());
//从x和y鼠标位置获取lat和long
点2D像素坐标1=点;
地理位置mappos=map.getTileFactory().pixelToGeo(pixelcoord1,map.getZoom());
Point2D QALLA=map.getTileFactory().geotoixel(mappos,map.getZoom());
//在该区域0.0015F的公共汽车站数据库中登记
ArrayList stops=DataAccess.GetBusStopByCoordinates((float)mappos.getLatitude(),(float)mappos.getLatitude(),0.0015F);
}
});
}    
jXMapKit1.getMainMap().convertPointToGeoPosition(pixelcoord1)

可能是重复的: