source: branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c @ 862

Last change on this file since 862 was 862, checked in by djay, 6 years ago

Add the capability to publish heatmap or any templated mapfile using the epecific msInclude and msLayer keys for an output. For MapServer? published output, define 4096 as the default maxsize and use pixel width or height for raster files. use the correct MapServer? imagemode depending on GDALGetRasterDataType (MS_IMAGEMODE_BYTE for GDT_Byte, MS_IMAGEMODE_INT16 for GDT_Int16 and MS_IMAGEMODE_FLOAT32 for GDT_Float32). Create a text file (.maps) listing every mapfiles created for a MapServer? published output (or inputs) using saveMapNames function. Fixes in ulinet, use uuid for naming temporary files. Add dialect input to the ogr2ogr service. Use the .maps file for removing a file from the DeleteData? service

File size: 3.3 KB
Line 
1/**
2 * Author : Gérald FENOY
3 *
4 * Copyright 2009-2013 GeoLabs SARL. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#include "cgal_service.h"
25
26int parseInput(maps* conf,maps* inputs, std::vector<Pointz>* points,char* filename){
27  map* tmpm=NULL;
28  tmpm=getMapFromMaps(inputs,"InputPoints","value");
29  VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmpm->value,strlen(tmpm->value),FALSE);
30  VSIFCloseL(ifile);
31#if GDAL_VERSION_MAJOR >= 2
32  GDALDataset *ipoDS =
33    (GDALDataset*) GDALOpenEx( filename,
34                               GDAL_OF_READONLY | GDAL_OF_VECTOR,
35                               NULL, NULL, NULL );
36#else
37  OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);
38#endif
39  if( ipoDS == NULL )
40    {
41#if GDAL_VERSION_MAJOR >= 2
42      GDALDriverManager* poR=GetGDALDriverManager();
43#else
44      OGRSFDriverRegistrar    *poR = OGRSFDriverRegistrar::GetRegistrar();
45#endif
46     
47      fprintf( stderr, "FAILURE:\n"
48               "Unable to open datasource `%s' with the following drivers.\n",
49               filename );
50     
51      for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
52        {
53#if GDAL_VERSION_MAJOR >= 2
54            fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetDescription() );
55#else
56            fprintf( stderr, "  -> %s\n", poR->GetDriver(iDriver)->GetName() );
57#endif
58        }
59      char tmp[1024];
60      sprintf(tmp,"Unable to open datasource `%s' with the following drivers.",filename);
61      setMapInMaps(conf,"lenv","message",tmp);
62      return SERVICE_FAILED;
63    }
64  for( int iLayer = 0; iLayer < ipoDS->GetLayerCount();
65       iLayer++ )
66    {
67      OGRLayer        *poLayer = ipoDS->GetLayer(iLayer);
68     
69      if( poLayer == NULL )
70        {
71          fprintf( stderr, "FAILURE: Couldn't fetch advertised layer %d!\n",
72                   iLayer );
73#ifdef ZOO_SERVICE
74          char tmp[1024];
75          sprintf(tmp,"Couldn't fetch advertised layer %d!",iLayer);
76          setMapInMaps(conf,"lenv","message",tmp);
77          return SERVICE_FAILED;
78#else
79          exit( 1 );
80#endif
81        }
82     
83      OGRFeature  *poFeature;
84      while(TRUE){
85        poFeature = poLayer->GetNextFeature();
86        if( poFeature == NULL )
87          break;
88        if(poFeature->GetGeometryRef() != NULL){
89          points->push_back(Pointz(OGR_G_GetX(poFeature->GetGeometryRef(),0),OGR_G_GetY(poFeature->GetGeometryRef(),0)));
90        }
91      }
92    }
93  return SERVICE_SUCCEEDED;
94}
95
96
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png