⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitsofmeasuremap.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.common.math;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.esri.arcgis.system.esriUnits;
import com.esri.solutions.jitk.common.resources.TextResources;

@SuppressWarnings("serial")
public class UnitsOfMeasureMap extends LinkedHashMap<Integer, String> {
	private static final Logger _logger = Logger.getLogger(UnitsOfMeasureMap.class);
	
	public UnitsOfMeasureMap() {
		super();
		
		buildMap();
	}
	
	public Integer getUnit(String unit) throws Exception {		
		Integer unitOfMeasure = null;
		
		if (this.containsValue(unit)) {
			Iterator<Map.Entry<Integer, String>> entries = null;
			Map.Entry<Integer, String> entry = null;
			entries = this.entrySet().iterator();
			int mapSize = this.size();
			
			for (int i = 0; i < mapSize; i++) {
				entry = (Map.Entry<Integer, String>) entries.next();
			  
				if (entry.getValue().equals(unit)) {
					unitOfMeasure = new Integer(entry.getKey());
				}
			}
		}
		else {
			_logger.error("Unit of measure could not be found in map list");
			throw new Exception("Unit of measure could not be found in map list");
		}
		
		if (unitOfMeasure == null) {
			_logger.error("Unit of measure could not be found in map list");
			throw new Exception("Unit of measure could not be found in map list");			
		}
		
		return unitOfMeasure;
	}

	protected void buildMap() {
		try {
			this.put(new Integer(esriUnits.esriInches), getVal(MeasureResourceProps.INCHES));
			this.put(new Integer(esriUnits.esriPoints), getVal(MeasureResourceProps.POINTS));
			this.put(new Integer(esriUnits.esriFeet), getVal(MeasureResourceProps.FEET));
			this.put(new Integer(esriUnits.esriYards), getVal(MeasureResourceProps.YARDS));
			this.put(new Integer(esriUnits.esriMiles), getVal(MeasureResourceProps.MILES));
			this.put(new Integer(esriUnits.esriNauticalMiles), getVal(MeasureResourceProps.NAUTICAL_MILES));
			this.put(new Integer(esriUnits.esriMillimeters), getVal(MeasureResourceProps.MILLIMETERS));
			this.put(new Integer(esriUnits.esriCentimeters), getVal(MeasureResourceProps.CENTIMETERS));
			this.put(new Integer(esriUnits.esriMeters), getVal(MeasureResourceProps.METERS)); ;
			this.put(new Integer(esriUnits.esriKilometers), getVal(MeasureResourceProps.KILOMETERS));
			this.put(new Integer(esriUnits.esriDecimalDegrees), getVal(MeasureResourceProps.DECIMAL_DEGREES));
			this.put(new Integer(esriUnits.esriDecimeters), getVal(MeasureResourceProps.DECIMETERS));
		}
		catch (Exception e) {
			_logger.error("Unable to build unit of measure map list", e);
		}
	}	
	
	private String getVal(String resourceName) {
		return TextResources.getResourceString(resourceName);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -