根据经纬度生成小区边框(区域)

package com.nokia.scenes.area;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.nokia.scenes.business.business1.mapper.shi.SuanFaMapper;

@SpringBootTest
@RunWith(SpringRunner.class)
public class getArea{
	
	@Autowired
	private SuanFaMapper suanFaMapper;
	
	@Test
	public void getDataFromResource(){
		Double beadmwidth = 130.0;
		Double outRadius = 200.0 * 0.000009;
		Double inRadius = 0.0 * 0.000009;
		List<Map<String, Object>> list = suanFaMapper.getDataFromRepo();
		List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
		for(int i = 0 ; i < list.size(); i++){
			Map<String, Object> map = list.get(i);
			if(map.get("longitude") != null && map.get("latitude") != null && map.get("azimuth") != null){
				Double longitude = Double.parseDouble(to_String(map.get("longitude")));
				Double latitude = Double.parseDouble(to_String(map.get("latitude")));
				Double azimuth = Double.parseDouble(to_String(map.get("azimuth")));
				String returnStr = getVmap("室外", longitude, latitude, azimuth, beadmwidth, outRadius, inRadius);
				String str = returnStr.replaceAll(";", ",");
				map.put("str", str);
				resList.add(map);
			}
		}
		int count = resList.size();
		List<Map<String, Object>> sqlList = null;
		int data = 1000;
		int x = count / data;
		int y = count % data;
		int j = 1;
		while(j <= x){
			sqlList = new ArrayList<Map<String,Object>>();
			for(int i = (j - 1) * 1000; i < j * 1000; i++){
				sqlList.add(resList.get(i));
			}
			suanFaMapper.insertToTable(sqlList);
			j++;
		}
		if(y != 0){
			sqlList = new ArrayList<Map<String,Object>>();
			for(int i = x * 1000; i < count; i++){
				sqlList.add(resList.get(i));
			}
			suanFaMapper.insertToTable(sqlList);
		}
		System.out.println(resList.size());
	}
	
//	@Test
	public void getData() {
		double outRadius = 100 * 0.000009;
		String str = getVmap("室外", 113.362950, 22.917890, 260.0, 130.0, outRadius, 0.0);
		System.out.println(str);
	}

	// SITETYPE 覆盖类型(室内和室外) LONGITUDE 经度 LATITUDE 纬度 AZIMUTH 方位角 BEAMWIDTH 130
	// outRadius 外经 (挂高*1.2) inRadius 内径 0
	public static String getVmap(String SITETYPE, Double LONGITUDE, Double LATITUDE, Double AZIMUTH, Double BEAMWIDTH,
			Double outRadius, Double inRadius) {
		String vamp = "";
		if (SITETYPE != null & SITETYPE.trim().equals("室外")) {
			vamp = GetMarcoArcPoints(LONGITUDE, LATITUDE, AZIMUTH, BEAMWIDTH, outRadius, inRadius);
		} else {
			vamp = GetIndoorArcPoints(LONGITUDE, LATITUDE, outRadius, inRadius);
		}
		return vamp;
	}

	public static String getSGEO(String SITETYPE, Double LONGITUDE, Double LATITUDE, Double AZIMUTH, Double BEAMWIDTH,
			Double outCAL_RADIUS, Double inCAL_RADIUS) {
		String vmapnew = "";
		if (SITETYPE != null & SITETYPE.trim().equals("室外")) {
			vmapnew = GetMarcoArcPoints(LONGITUDE, LATITUDE, AZIMUTH, BEAMWIDTH, outCAL_RADIUS, inCAL_RADIUS);
		} else {
			vmapnew = GetIndoorArcPoints(LONGITUDE, LATITUDE, outCAL_RADIUS, inCAL_RADIUS);
		}
		vmapnew = vmapnew.replaceAll(";", ",");
		if (vmapnew.length() > 0 & vmapnew.trim().substring(vmapnew.length() - 1, vmapnew.length()).equals(",")) {
			vmapnew = vmapnew.substring(0, vmapnew.length() - 1);
		}
		return vmapnew;

	}

	public static String GetMarcoArcPoints(double x, double y, double dir, double bw, double outRadius,
			double inRadius) {
		String points = "";
		DecimalFormat df2 = new DecimalFormat("#0.000000");
		try {
			String[] x1s = new String[5];
			String[] y1s = new String[5];
			for (int j = 1; j < 6; j++) {
				double tx = x + outRadius * Math.cos(Math.PI / 180 * (90 - dir + (3 - j) * bw / 5));
				x1s[j - 1] = df2.format(tx);
				double ty = y + outRadius * Math.sin(Math.PI / 180 * (90 - dir + (3 - j) * bw / 5));
				y1s[j - 1] = df2.format(ty);
				;
			}
			if (inRadius == outRadius) {
				points = df2.format(x) + " " + df2.format(y) + ";" + x1s[0] + " " + y1s[0] + ";" + x1s[1] + " " + y1s[1]
						+ ";" + x1s[2] + " " + y1s[2] + ";" + x1s[3] + " " + y1s[3] + ";" + x1s[4] + " " + y1s[4];
			} else {
				String[] x2s = new String[5];
				String[] y2s = new String[5];
				for (int j = 1; j < 6; j++) {
					double tx = x + inRadius * Math.cos(Math.PI / 180 * (90 - dir + (3 - j) * bw / 5));
					x2s[j - 1] = df2.format(tx);
					double ty = y + inRadius * Math.sin(Math.PI / 180 * (90 - dir + (3 - j) * bw / 5));
					y2s[j - 1] = df2.format(ty);
				}
				points = df2.format(x) + " " + df2.format(y) + ";" + x1s[0] + " " + y1s[0] + ";" + x1s[1] + " " + y1s[1]
						+ ";" + x1s[2] + " " + y1s[2] + ";" + x1s[3] + " " + y1s[3] + ";" + x1s[4] + " " + y1s[4] + ";"
						+ df2.format(x) + " " + df2.format(y) + ";" + x2s[4] + " " + y2s[4] + ";" + x2s[3] + " "
						+ y2s[3] + ";" + x2s[2] + " " + y2s[2] + ";" + x2s[1] + " " + y2s[1] + ";" + x2s[0] + " "
						+ y2s[0];
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return points;
	}

	public static String GetIndoorArcPoints(double x, double y, double outRadius, double inRadius) {
		String points = "";
		DecimalFormat df2 = new DecimalFormat("#0.000000");
		try {
			String[] x1s = new String[3];
			String[] y1s = new String[3];
			double[] dirs = { 60, 180, 300 };
			double bw = 120;
			for (int i = 0; i < dirs.length; i++) {
				double dir = dirs[i];
				double tx = x + outRadius * Math.cos(Math.PI / 180 * (90 - dir + (9 - 1) * bw / 16));
				x1s[i] = df2.format(tx);
				double ty = y + outRadius * Math.sin(Math.PI / 180 * (90 - dir + (9 - 1) * bw / 16));
				y1s[i] = df2.format(ty);
				;
			}
			if (inRadius == outRadius) {
				points = x1s[0] + " " + y1s[0] + ";" + x1s[1] + " " + y1s[1] + ";" + x1s[2] + " " + y1s[2];
			} else {
				String[] x2s = new String[3];
				String[] y2s = new String[3];
				for (int i = 0; i < dirs.length; i++) {
					double dir = dirs[i];
					double tx = x + inRadius * Math.cos(Math.PI / 180 * (90 - dir + (9 - 1) * bw / 16));
					x2s[i] = df2.format(tx);
					double ty = y + inRadius * Math.sin(Math.PI / 180 * (90 - dir + (9 - 1) * bw / 16));
					y2s[i] = df2.format(ty);
					;
				}
				points = x1s[0] + " " + y1s[0] + ";" + x1s[1] + " " + y1s[1] + ";" + x1s[2] + " " + y1s[2] + ";"
						+ x1s[0] + " " + y1s[0] + ";" + x2s[0] + " " + y2s[0] + ";" + x2s[2] + " " + y2s[2] + ";"
						+ x2s[1] + " " + y2s[1] + ";" + x2s[0] + " " + y2s[0];
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return points;
	}
	
	public String to_String(Object obj){
        String str = "";
        if(null != obj){
            str =  obj + "";
        }
        return str;
    }
}

 

1、 批量生成标准分幅图或行政区划,地图打印所需的图廓(或图框)整饰内容:公里网,十字丝,经纬网以及标注,四角的经纬度标注,四周的文字表示和自动填写结合表的内容。一方面标准规范,另一方大大地提高了你的工作效率,使你在打印地图中,从重复、繁杂的工作中摆脱出来。 2、 系统缺省按照地形图标准设置,也提供各种参数定制:如地图比例尺, 地图左下角,下面的比例尺信息,右下角,左边的单位信息,右上角(机密等),上边的标题,内容,位置,字体的大小,颜色都可以自己定义,提供公里网,十字丝,经纬网三种方式供你选择,你可以设置公里网,十字丝,经纬网的间距,文字标注的大小位置。 3、 比例尺可以自己指定,根据比例尺,自动计算各文字注记得位置。 4、 输入一图幅号,就可以生成对应图幅图廓整饰内容。提供标准图幅号(可以是新图幅也可以是旧图幅号,支持地图比例尺有1:100万、1:50万、1:25万、1:10万、1:5万、1:2.5万、1:1万和1:5000比例尺))生成单幅图的打印梯形图廓,内外图廓严格平行,都是梯形,文字标注按照梯形的斜线标注;根据标准图幅文件批量生成标准梯形图廓;根据行政区划文件的图形对象,批量生成矩形图廓,你可以定义地图与内图廓的距离,可以采用经纬网标注整饰,比例尺也可以灵活自定义。 5、 标注智能化程度高,要求左对齐,一定左对齐,中间对齐自动中间对齐,右对齐自动右对齐,位置严格按照定义位置标注,字体大小,颜色样式一定定义生成,并且可以和字段、或则日期配套使用。 本软件是绿色软件,无需安装,操作方便,自动记忆上次界面设置,下次打开就自动调出上次设置,包括文字的内容,字体的大小,颜色,你的选择(如本次选经纬网,下次打开默认设置还是经纬网),让你真正一劳永逸。有其他特殊需要和问题,都可以发Email:gisoracle@126.com, 635211942@qq.com或QQ:276529800, 635211942联系,定会得到答复。 本工具有ArcGIS和Mapinfo版,本说明主要针对MapInfo版 注意:需要安装mapinfo6.0以上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值