001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2025 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas/ 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see https://www.gnu.org/licenses/. 027 */ 028 029package edu.wisc.ssec.mcidasv.data; 030 031import ucar.unidata.geoloc.ProjectionImpl; 032import ucar.unidata.geoloc.ProjectionRect; 033import ucar.unidata.geoloc.projection.LatLonProjection; 034 035/** 036 * An extension of {@code LatLonProjection} that adds properties for 037 * the center point and dimensions of the projection box. Appropriate 038 * getters and setters are added so they will be picked up by the 039 * {@code ProjectionImpl} and thereby editable by the user. 040 * 041 * @author McIDAS-V Dev Team, UW SSEC 042 */ 043public class McIDASVLatLonProjection extends LatLonProjection { 044 045 private static final long serialVersionUID = -4939597425144220140L; 046 047 public McIDASVLatLonProjection() { 048 this(""); 049 } 050 051 public McIDASVLatLonProjection(String name) { 052 this(name, new ProjectionRect(-180, -90, 180, 90)); 053 } 054 055 public McIDASVLatLonProjection(String name, ProjectionRect mapArea) { 056 addParameter("grid_mapping_name", "McVLatLon"); 057 this.name = name; 058 defaultMapArea = mapArea; 059 } 060 061 /** 062 * Get the class name 063 * @return class name 064 */ 065 public String getClassName() { 066 return "McVLatLon"; 067 } 068 069 070 /** 071 * Get the label to be used in the gui for this type of projection 072 * 073 * @return Type label 074 */ 075 public String getProjectionTypeLabel() { 076 return "McV Lat/Lon"; 077 } 078 079 /** 080 * Set the center of the projection box X coord. 081 * @param x 082 */ 083 public void setCenterX(double x) { 084 defaultMapArea.setX(x - defaultMapArea.getWidth() / 2); 085 } 086 087 /** 088 * Set the center of the projection box Y coord. 089 * @param y 090 */ 091 public void setCenterY(double y) { 092 defaultMapArea.setY(y - defaultMapArea.getHeight() / 2); 093 } 094 095 /** 096 * Set the overall width of the projection box. 097 * @param w 098 */ 099 public void setLonWidth(double w) { 100 defaultMapArea.setWidth(w); 101 } 102 103 /** 104 * Set the overall height of the projection box 105 * @param h 106 */ 107 public void setLatHeight(double h) { 108 defaultMapArea.setHeight(h); 109 } 110 111 public double getCenterX() { 112 return defaultMapArea.getCenterX() + defaultMapArea.getWidth() / 2; 113 } 114 115 public double getCenterY() { 116 return defaultMapArea.getCenterY() + defaultMapArea.getHeight() / 2; 117 } 118 119 public double getLonWidth() { 120 return defaultMapArea.getWidth(); 121 } 122 123 public double getLatHeight() { 124 return defaultMapArea.getHeight(); 125 } 126 127 /** 128 * Make the default display projection 129 * @return Default display projection 130 */ 131 protected ProjectionImpl makeDefaultProjection() { 132 return new McIDASVLatLonProjection("World", 133 new ProjectionRect(-180., -180., 180., 134 180.)); 135 } 136 137}