小编Jer*_*ook的帖子

REST:映射404 HTTP状态代码

我们的团队正在开发RESTFul应用程序......我们正在讨论"最佳实践"方法.

是否应该为类似过滤器的查询返回404状态代码响应?说我的GET URL是

.../1 /服务/ startsWith/a.json

并且它返回在我的数据库中以A开头的所有值...但如果没有找到"a"值,我应该只返回带有空json字符串的状态代码200吗?或状态代码404.

谢谢!

rest web-services restlet

12
推荐指数
1
解决办法
7914
查看次数

使用Spring Data,Mongodb,如何避免重复顶点错误

我在我导入的一个多边形中得到了错误.

Write failed with error code 16755 and error message 'Can't extract geo keys: { _id: "b9c5ac0c-e469-4b97-b059-436cd02ffe49", _class: .... ] Duplicate vertices: 0 and 15'
Run Code Online (Sandbox Code Playgroud)

完整堆栈跟踪:https://gist.github.com/boundaries-io/927aa14e8d1e42d7cf516dc25b6ebb66#file-stacktrace

GeoJson MultiPolygon我使用Spring Data MongoDB导入

public class MyPolgyon {

    @Id
    String id;

    @GeoSpatialIndexed(type=GeoSpatialIndexType.GEO_2DSPHERE)
    GeoJsonPoint position;

    @GeoSpatialIndexed(type=GeoSpatialIndexType.GEO_2DSPHERE)
    GeoJsonPoint location;

    @GeoSpatialIndexed(type=GeoSpatialIndexType.GEO_2DSPHERE)
    GeoJsonPolygon polygon;





public static GeoJsonPolygon generateGeoJsonPolygon(List<LngLatAlt> coordinates) {
        List<Point> points = new ArrayList<Point>();
        for ( LngLatAlt  point: coordinates) {                          
                org.springframework.data.geo.Point dataPoint = new org.springframework.data.geo.Point( point.getLongitude() ,point.getLatitude());              
                points.add(dataPoint);          
            }   
        return new  GeoJsonPolygon(points);
    }
Run Code Online (Sandbox Code Playgroud)

我怎样才能在Java中避免这个错误? …

java spring mongodb

8
推荐指数
1
解决办法
575
查看次数

Java Date 8上的Java Instant.parse

我有一些旧的KML文档,其中包括时间戳记条目。为什么使用即时分析时,以下日期无效?假定这两种方法都可以解析ISO 8601格式的日期。

字符串dateString =“ 2017-12-04T08:06:60Z”

使用

java.time.Instant.parse(dateString)
Run Code Online (Sandbox Code Playgroud)

引发错误

"DateTimeParseException Text 2017-12-04T08:06:60Z could not be parsed at index 0."
Run Code Online (Sandbox Code Playgroud)

但是,使用时

Date myDate =   javax.xml.bind.DatatypeConverter.parseDateTime( dateString )
Run Code Online (Sandbox Code Playgroud)

myDate已正确解析。

java time kml datetime-parsing java.time

3
推荐指数
1
解决办法
359
查看次数

如何使用geoTools中的GeometricShapeFactory在地图上创建圆

我目前正在使用以下代码创建 GeoJson 多边形。这给我带来了一个无效的坏循环......

在本例中RADIUS = 1609.34 ,即 1 英里(以米为单位)。

        public  GeoJsonPolygon createRadiusPolygon(  Point point,double RADIUS) {       

              GeometricShapeFactory shapeFactory = new GeometricShapeFactory();
              shapeFactory.setNumPoints(32);
              shapeFactory.setCentre(new com.vividsolutions.jts.geom.Coordinate(point.getX(), point.getY()));
              shapeFactory.setSize(RADIUS * 2);
              com.vividsolutions.jts.geom.Geometry circle = shapeFactory.createCircle();
              List<Point> points = new ArrayList<Point>();
                for (com.vividsolutions.jts.geom.Coordinate coordinate : circle.getCoordinates()) {
                    Point lngLatAtl = new Point(coordinate.x, coordinate.y);
                    points.add(lngLatAtl);
                }
                Collections.reverse(points);
                return new GeoJsonPolygon(points);
            }
Run Code Online (Sandbox Code Playgroud)

参考: http ://docs.geotools.org/stable/userguide/library/jts/geometry.html

目前,如果我使用 Point(-73.87,40.84) RADIUS = 1609.34,我会得到以下链接。 https://gist.githubusercontent.com/VanitySoft/56c4ce0f5c1c7e7fe0461ed46fd5ed11/raw/94544750a140d81780ebe9206395a21ab88bb1f7/circle

===已解决== 来自@Ian 的回答:在他的回答中使用方法。RADIUS 以英里为单位,用于获取用于创建 GeoJson 的圆。

...
  com.vividsolutions.jts.geom.Point jtsPoint =  new GeometryFactory().createPoint(new com.vividsolutions.jts.geom.Coordinate(point.getY(), point.getX())); …
Run Code Online (Sandbox Code Playgroud)

java latitude-longitude geotools

1
推荐指数
1
解决办法
8049
查看次数