|
From: <joh...@ie...> - 2000-05-12 19:59:35
|
Patch: vhclmaps-000425-johnston-022
For: vhclmaps-0.7.4
Author: joh...@us...
Subject:
Requires: incorporate new files into MapServ directory
This is an intermediate patch to vhclmaps-0.7.4. To apply, cd to the
top-level directory of the vhclmaps source tree (the directory with src
and config subdirs), and apply like this:
patch -p0 <ThisFile
Summary of Changes:
- add MapServ/mapprojfunc.[ch], which contains utmzone, geotoutm, and
utmtogeo commands.
Index: MapServ/mapprojfunc.c
diff -c /dev/null MapServ/mapprojfunc.c:1.1
*** /dev/null Tue Apr 25 22:08:12 2000
--- src/MapServ/mapprojfunc.c Tue Apr 25 22:08:11 2000
***************
*** 0 ****
--- 1,124 ----
+ /*
+ * Copyright (c) 2000 IET Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+ #include <MapServ/mapprojfunc.h>
+ #include <Map/mapproject.h>
+ #include <Unidraw/iterator.h>
+ #include <Attribute/attrlist.h>
+ extern "C" {
+ #include <projects.h>
+ }
+
+ /*****************************************************************************/
+
+
+ UtmZoneFunc::UtmZoneFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void UtmZoneFunc::execute() {
+ ComValue longv(stack_arg(0));
+ reset_stack();
+ ComValue retval(MapProjection::utmzone(longv.float_val()));
+ push_stack(retval);
+ }
+
+ /*****************************************************************************/
+
+ UtmToGeoFunc::UtmToGeoFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void UtmToGeoFunc::execute() {
+ ComValue utmsv(stack_arg(0));
+ ComValue zonev(stack_arg(1));
+ reset_stack();
+ char zs[40];
+ sprintf(zs, "zone=%d", zonev.int_val());
+ char* parms[4];
+ parms[0] = "proj=utm";
+ parms[1] = "ellps=WGS84";
+ parms[2] = zs;
+ parms[3] = "no_defs";
+ PJ* proj= pj_init(4, parms);
+ AttributeValueList *avl = utmsv.is_type(ComValue::ArrayType)
+ ? utmsv.array_val() : nil;
+ if (avl && proj) {
+ Iterator i;
+ avl->First(i);
+ UV data;
+ data.u = avl->GetAttrVal(i)->double_val();
+ avl->Next(i);
+ data.v = avl->GetAttrVal(i)->double_val();
+ data = pj_inv(data, proj);
+ double lon = data.u * RAD_TO_DEG;
+ double lat = data.v * RAD_TO_DEG;
+ AttributeValueList* navl = new AttributeValueList();
+ navl->Append(new ComValue(lon));
+ navl->Append(new ComValue(lat));
+ ComValue retval(navl);
+ push_stack(retval);
+ }
+ delete proj;
+ }
+
+ /*****************************************************************************/
+
+ GeoToUtmFunc::GeoToUtmFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void GeoToUtmFunc::execute() {
+ ComValue lonlatv(stack_arg(0));
+ reset_stack();
+ AttributeValueList *avl = lonlatv.is_type(ComValue::ArrayType)
+ ? lonlatv.array_val() : nil;
+ if (avl && avl->Number()==2) {
+ Iterator i;
+ avl->First(i);
+ double lon = avl->GetAttrVal(i)->double_val();
+ avl->Next(i);
+ double lat = avl->GetAttrVal(i)->double_val();
+ char ls[40];
+ sprintf(ls, "lon_0=%f", lon);
+ char* parms[4];
+ parms[0] = "proj=utm";
+ parms[1] = "ellps=WGS84";
+ parms[2] = ls;
+ parms[3] = "no_defs";
+ PJ* proj= pj_init(4, parms);
+ if (proj) {
+ UV data;
+ data.u = lon * DEG_TO_RAD;
+ data.v = lat * DEG_TO_RAD;
+ data = pj_fwd(data, proj);
+ double lat = data.v * RAD_TO_DEG;
+ AttributeValueList* navl = new AttributeValueList();
+ navl->Append(new ComValue(data.u));
+ navl->Append(new ComValue(data.v));
+ ComValue retval(navl);
+ push_stack(retval);
+ }
+ delete proj;
+ }
+ }
+
+
+
Index: MapServ/mapprojfunc.h
diff -c /dev/null MapServ/mapprojfunc.h:1.1
*** /dev/null Tue Apr 25 22:08:13 2000
--- src/MapServ/mapprojfunc.h Tue Apr 25 22:08:11 2000
***************
*** 0 ****
--- 1,59 ----
+ /*
+ * Copyright (c) 2000 IET Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+ #ifndef mapprojfunc_h
+ #define mapprojfunc_h
+
+ #include <ComTerp/comfunc.h>
+ #include <ComTerp/comterp.h>
+
+ class UtmZoneFunc : public ComFunc {
+ public:
+ UtmZoneFunc(ComTerp*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "int=%s(longitude) -- return utm zone for given longitude"; }
+ };
+
+ class UtmToGeoFunc : public ComFunc {
+ public:
+ UtmToGeoFunc(ComTerp*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "long,lat=%s(utme,utmn zone) -- convert utm to geo (longitude/latitude)"; }
+ };
+
+ class GeoToUtmFunc : public ComFunc {
+ public:
+ GeoToUtmFunc(ComTerp*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "utme,utmn=%s(long,lat) -- convert geo (longitude/latitude) to utm"; }
+ };
+
+ #endif
+
+
+
+
+
*** /dev/null Tue Apr 25 22:08:18 PDT 2000
--- patches/vhclmaps-000425-johnston-022
*************** patches/vhclmaps-000425-johnston-022
*** 0 ****
--- 1 ----
+ vhclmaps-000425-johnston-022
|