空间类相关方法
This commit is contained in:
parent
b5861722b4
commit
f84e6e039c
@ -19,20 +19,25 @@ public class App {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ApplicationContext context = ApplicationInit();
|
ApplicationContext context = ApplicationInit();
|
||||||
ViewService viewService = context.getBean(ViewService.class);
|
ViewService viewService = context.getBean(ViewService.class);
|
||||||
View view = new View();
|
|
||||||
String id = UUID.randomUUID().toString();
|
|
||||||
|
|
||||||
view.setViewId(id);
|
View view = viewService.findeViewById("a20d41b4-208d-47da-8c02-e7023fc4e9f4");
|
||||||
System.out.println(view.getViewId());
|
System.out.println("["+ ((Double[])view.getCenter())[0] + ", " + ((Double[])view.getCenter())[1] + "]");
|
||||||
view.setViewName("测试视图");
|
|
||||||
view.setCenter(new Double[]{117.089151, 36.738693});
|
|
||||||
view.setProjection("EPSG:4326");
|
|
||||||
view.setMinZoom(8);
|
|
||||||
view.setMaxZoom(18);
|
|
||||||
view.setZoom(9);
|
|
||||||
|
|
||||||
viewService.insertView(view);
|
|
||||||
System.out.println("插入成功");
|
// View view = new View();
|
||||||
|
// String id = UUID.randomUUID().toString();
|
||||||
|
//
|
||||||
|
// view.setViewId(id);
|
||||||
|
// System.out.println(view.getViewId());
|
||||||
|
// view.setViewName("测试视图");
|
||||||
|
// view.setCenter(new Double[]{117.089151, 36.738693});
|
||||||
|
// view.setProjection("EPSG:4326");
|
||||||
|
// view.setMinZoom(8);
|
||||||
|
// view.setMaxZoom(18);
|
||||||
|
// view.setZoom(9);
|
||||||
|
//
|
||||||
|
// viewService.insertView(view);
|
||||||
|
// System.out.println("插入成功");
|
||||||
|
|
||||||
// MapService mapService = context.getBean(MapService.class);
|
// MapService mapService = context.getBean(MapService.class);
|
||||||
// Map map = mapService.findAllList().get(0);
|
// Map map = mapService.findAllList().get(0);
|
||||||
|
|||||||
@ -4,11 +4,13 @@ import org.apache.ibatis.type.BaseTypeHandler;
|
|||||||
import org.apache.ibatis.type.JdbcType;
|
import org.apache.ibatis.type.JdbcType;
|
||||||
import org.apache.ibatis.type.TypeException;
|
import org.apache.ibatis.type.TypeException;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hukekuan on 2017/12/15.
|
* Created by hukekuan on 2017/12/15.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ArrayTypeHandler extends BaseTypeHandler<Object[]> {
|
public class ArrayTypeHandler extends BaseTypeHandler<Object[]> {
|
||||||
private static final String TYPE_NAME_VARCHAR = "varchar";
|
private static final String TYPE_NAME_VARCHAR = "varchar";
|
||||||
private static final String TYPE_NAME_BOOLEAN = "boolean";
|
private static final String TYPE_NAME_BOOLEAN = "boolean";
|
||||||
@ -32,11 +34,13 @@ public class ArrayTypeHandler extends BaseTypeHandler<Object[]> {
|
|||||||
if (typeName == null) {
|
if (typeName == null) {
|
||||||
throw new TypeException("ArrayTypeHandler parameter typeName error, your type is " + parameter.getClass().getName());
|
throw new TypeException("ArrayTypeHandler parameter typeName error, your type is " + parameter.getClass().getName());
|
||||||
}
|
}
|
||||||
System.out.println("======= "+ typeName +" =======");
|
|
||||||
Array array = ps.getConnection().createArrayOf(typeName, parameter);
|
Array array = ps.getConnection().createArrayOf(typeName, parameter);
|
||||||
ps.setArray(i, array);
|
ps.setArray(i, array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
public Object[] getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||||
return getArray(rs.getArray(columnName));
|
return getArray(rs.getArray(columnName));
|
||||||
|
|||||||
@ -16,8 +16,8 @@ create table c3gis_ol_map(
|
|||||||
create table c3gis_ol_view(
|
create table c3gis_ol_view(
|
||||||
viewid varchar(50) not null PRIMARY KEY,
|
viewid varchar(50) not null PRIMARY KEY,
|
||||||
viewname varchar(50) not null,
|
viewname varchar(50) not null,
|
||||||
center NUMERIC(14,6) ARRAY[2],
|
center double precision ARRAY[2],
|
||||||
extent NUMERIC(14,6) ARRAY[4],
|
extent double precision ARRAY[4],
|
||||||
maxresolution varchar(50),
|
maxresolution varchar(50),
|
||||||
minresolution varchar(50),
|
minresolution varchar(50),
|
||||||
maxzoom int,
|
maxzoom int,
|
||||||
|
|||||||
@ -2,24 +2,23 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.gis3c.ol.dao.ViewDao">
|
<mapper namespace="com.gis3c.ol.dao.ViewDao">
|
||||||
<resultMap id="viewResult" type="com.gis3c.ol.entity.View">
|
<resultMap id="viewResult" type="com.gis3c.ol.entity.View">
|
||||||
<result property="viewId" column="viewid"/>
|
<result property="viewId" column="viewid" />
|
||||||
<result property="viewName" column="viewname" />
|
<result property="viewName" column="viewname" />
|
||||||
<result property="center" column="center" javaType="Object"/>
|
<result property="center" column="center" javaType="ObjectArray"/>
|
||||||
<result property="extent" column="extent" javaType="Object"/>
|
<result property="extent" column="extent" javaType="ObjectArray"/>
|
||||||
<result property="maxResolution" column="maxresolution" />
|
|
||||||
<result property="minResolution" column="minresolution" />
|
<result property="minResolution" column="minresolution" />
|
||||||
<result property="maxZoom" column="maxzoom" />
|
<result property="maxZoom" column="maxzoom" />
|
||||||
<result property="minZoom" column="minzoom" />
|
<result property="minZoom" column="minzoom" />
|
||||||
<result property="zoom" column="zoom" />
|
<result property="zoom" column="zoom" />
|
||||||
<result property="projection" column="projection" />
|
<result property="projection" column="projection" />
|
||||||
<result property="resolution" column="resolution" />
|
<result property="resolution" column="resolution" />
|
||||||
<result property="resolutions" column="resolutions" javaType="Object"/>
|
<result property="resolutions" column="resolutions" javaType="ObjectArray"/>
|
||||||
<result property="rotation" column="rotation" />
|
<result property="rotation" column="rotation" />
|
||||||
<result property="description" column="description" />
|
<result property="description" column="description" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="viewColumns">
|
<sql id="viewColumns">
|
||||||
v.viewid
|
viewid
|
||||||
, v.viewname
|
, v.viewname
|
||||||
, v.center
|
, v.center
|
||||||
, v.extent
|
, v.extent
|
||||||
@ -39,7 +38,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
<include refid="viewColumns"/>
|
<include refid="viewColumns"/>
|
||||||
FROM c3gis_ol_view v
|
FROM c3gis_ol_view v
|
||||||
WHERE v.viewid = #{viewId};
|
WHERE v.viewid = #{viewId, javaType=java.lang.String};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findeViewByName" resultMap="viewResult">
|
<select id="findeViewByName" resultMap="viewResult">
|
||||||
@ -69,8 +68,8 @@
|
|||||||
VALUES(
|
VALUES(
|
||||||
#{viewId}
|
#{viewId}
|
||||||
, #{viewName}
|
, #{viewName}
|
||||||
, #{center}
|
, #{center, javaType=ObjectArray}
|
||||||
, #{extent}
|
, #{extent, javaType=ObjectArray}
|
||||||
, #{maxResolution}
|
, #{maxResolution}
|
||||||
, #{minResolution}
|
, #{minResolution}
|
||||||
, #{maxZoom}
|
, #{maxZoom}
|
||||||
@ -78,7 +77,7 @@
|
|||||||
, #{zoom}
|
, #{zoom}
|
||||||
, #{projection}
|
, #{projection}
|
||||||
, #{resolution}
|
, #{resolution}
|
||||||
, #{resolutions}
|
, #{resolutions, javaType=ObjectArray}
|
||||||
, #{rotation}
|
, #{rotation}
|
||||||
, #{description});
|
, #{description});
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@ -45,9 +45,9 @@
|
|||||||
<typeHandler handler="com.gis3c.common.OracleSpatialHandler" javaType="Geometry" />
|
<typeHandler handler="com.gis3c.common.OracleSpatialHandler" javaType="Geometry" />
|
||||||
</typeHandlers>-->
|
</typeHandlers>-->
|
||||||
<typeAliases>
|
<typeAliases>
|
||||||
<typeAlias type="java.lang.Object" alias="Object" />
|
<typeAlias type="java.lang.Object" alias="ObjectArray" />
|
||||||
</typeAliases>
|
</typeAliases>
|
||||||
<typeHandlers>
|
<typeHandlers>
|
||||||
<typeHandler handler="com.gis3c.spatial.postgis.ArrayTypeHandler" javaType="Object" />
|
<typeHandler handler="com.gis3c.spatial.postgis.ArrayTypeHandler" javaType="ObjectArray" />
|
||||||
</typeHandlers>
|
</typeHandlers>
|
||||||
</configuration>
|
</configuration>
|
||||||
Loading…
Reference in New Issue
Block a user