1
/************************************************************************************
2
TerraLib - a library for developing GIS applications.
3
Copyright ļæ½ 2001-2004 INPE and Tecgraf/PUC-Rio.
5
This code is part of the TerraLib library.
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
You should have received a copy of the GNU Lesser General Public
12
License along with this library.
14
The authors reassure the license terms regarding the warranties.
15
They specifically disclaim any warranties, including, but not limited to,
16
the implied warranties of merchantability and fitness for a particular purpose.
17
The library provided hereunder is on an "as is" basis, and the authors have no
18
obligation to provide maintenance, support, updates, enhancements, or modifications.
19
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
20
indirect, special, incidental, or consequential damages arising out of the use
21
of this library and its documentation.
22
*************************************************************************************/
24
#include "TeCellAlgorithms.h"
25
#include "TeGeometryAlgorithms.h"
26
#include "TeDatabase.h"
27
#include "TeProgress.h"
28
#include "TeRepresentation.h"
29
#include "TeGeneralizedProxMatrix.h"
32
TeCreateCells( const string& layerName, TeLayer* layerBase,
33
double resX, double resY, TeBox& box, bool mask)
35
if (!layerBase || layerName.empty())
38
TeDatabase* db = layerBase->database();
42
TeDatabasePortal* portal = db->getPortal();
46
TeProjection* proj = layerBase->projection();
48
string newLayerName = layerName;
49
TeLayerMap& layerMap = db->layerMap();
50
TeLayerMap::iterator it;
55
for (it = layerMap.begin(); it != layerMap.end(); ++it)
57
if (TeStringCompare(it->second->name(),newLayerName))
60
if (it == layerMap.end())
63
newLayerName = layerName + "_" +Te2String(n);
70
TeRepresentation* repp = layerBase->getRepresentation(TePOLYGONS);
74
box = adjustToCut(repp->box_,resX,resY);
75
polTableName = repp->tableName_;
83
box = adjustToCut(layerBase->box(),resX,resY);
86
TeBox newBox = adjustToCut(box,resX,resY);
87
double x,y,x1,x2,y1,y2;
93
int maxcols, maxlines;
94
maxlines = TeRound((y2-y1)/resY);
95
maxcols = TeRound((x2-x1)/resX);
97
TeAttribute attribute;
98
TeAttributeList attList;
99
attribute.rep_.name_ = "object_id_";
100
attribute.rep_.type_ = TeSTRING;
101
attribute.rep_.numChar_ = 48;
102
attribute.rep_.isPrimaryKey_ = true;
103
attList.push_back ( attribute );
104
attribute.rep_.name_ = "Col";
105
attribute.rep_.type_ = TeINT;
106
attList.push_back ( attribute );
107
attribute.rep_.name_ = "Lin";
108
attribute.rep_.type_ = TeINT;
109
attribute.rep_.isPrimaryKey_ = false;
110
attList.push_back ( attribute );
112
TeLayer* newLayer = new TeLayer(layerName,db,newBox,proj);
113
if (!newLayer || newLayer->id() <= 0)
118
newLayer->addGeometry(TeCELLS);
119
TeRepresentation* repp = newLayer->getRepresentation(TeCELLS);
122
db->deleteLayer(newLayer->id());
129
repp->nCols_ = maxcols;
130
repp->nLins_ = maxlines;
131
db->updateRepresentation(newLayer->id(),*repp);
133
TeTable attTable (layerName,attList,"object_id_","object_id_",TeAttrStatic);
134
newLayer->createAttributeTable(attTable);
142
if(TeProgress::instance())
143
TeProgress::instance()->setTotalSteps(maxlines);
148
TePrecision::instance().setPrecision(TeGetPrecision(proj));
151
for (lin=0; lin<maxlines; ++lin)
157
for (col=0; col<maxcols; ++col)
159
TeBox box(x,y,x+resX,yu);
161
// check if there should be used the polygon representation as a mask
164
TePolygon polBox = polygonFromBox(box);
165
// check if the cell intersects the current polygon
166
if (TeIntersects(polBox,curPol))
170
if (db->spatialRelation(polTableName, TePOLYGONS,
171
(TePolygon*)&polBox, portal, TeINTERSECTS))
173
portal->fetchGeometry(curPol);
176
portal->freeResult();
183
TeCell cell(box,col,lin);
185
sprintf(celId,"C%02dL%02d",col,lin);
186
cell.objectId(string(celId));
189
// build default attributes
191
row.push_back(cell.objectId());
192
row.push_back(Te2String(col));
193
row.push_back(Te2String(lin));
199
if (attTable.size() > 0) // if there is some attributes in this line
201
status = newLayer->saveAttributeTable(attTable);
203
status = newLayer->addCells(cells);
205
if(TeProgress::instance())
207
if (TeProgress::instance()->wasCancelled())
210
TeProgress::instance()->setProgress(lin);
215
if (TeProgress::instance())
216
TeProgress::instance()->reset();
222
db->deleteLayer(newLayer->id());
229
TeCreateCells(const string& layerName,TeTheme* theme, double resX, double resY, TeBox& box)
231
TeLayer* inputLayer = theme->layer();
232
TeRepresentation* pp = inputLayer->getRepresentation(TePOLYGONS);
236
TeDatabase* db = inputLayer->database();
237
TeDatabasePortal* portal = db->getPortal();
241
string newLayerName = layerName;
242
TeLayerMap& layerMap = db->layerMap();
243
TeLayerMap::iterator it;
248
for (it = layerMap.begin(); it != layerMap.end(); ++it)
250
if (TeStringCompare(it->second->name(),newLayerName))
253
if (it == layerMap.end())
256
newLayerName = layerName + "_" +Te2String(n);
263
TeBox newBox = adjustToCut(box,resX,resY);
264
double x,y,x1,x2,y1,y2;
270
int maxcols, maxlines;
271
maxlines = TeRound((y2-y1)/resY);
272
maxcols = TeRound((x2-x1)/resX);
274
TeAttribute attribute;
275
TeAttributeList attList;
276
attribute.rep_.name_ = "object_id_";
277
attribute.rep_.type_ = TeSTRING;
278
attribute.rep_.isPrimaryKey_ = true;
279
attribute.rep_.numChar_ = 48;
280
attList.push_back ( attribute );
282
attribute.rep_.name_ = "Col";
283
attribute.rep_.type_ = TeINT;
284
attribute.rep_.isPrimaryKey_ = false;
285
attList.push_back ( attribute );
287
attribute.rep_.name_ = "Lin";
288
attribute.rep_.type_ = TeINT;
289
attribute.rep_.isPrimaryKey_ = false;
290
attList.push_back ( attribute );
292
TeLayer* newLayer = new TeLayer(layerName,db,newBox,inputLayer->projection());
293
if (!newLayer || newLayer->id() <= 0)
298
newLayer->addGeometry(TeCELLS);
299
TeRepresentation* repp = newLayer->getRepresentation(TeCELLS);
302
db->deleteLayer(newLayer->id());
309
repp->nCols_ = maxcols;
310
repp->nLins_ = maxlines;
311
db->updateRepresentation(newLayer->id(),*repp);
313
TeTable attTable (layerName,attList,"object_id_","object_id_",TeAttrStatic);
314
newLayer->createAttributeTable(attTable);
316
string polTableName = inputLayer->tableName(TePOLYGONS);
327
TePrecision::instance().setPrecision(TeGetPrecision(newLayer->projection()));
329
if(TeProgress::instance())
330
TeProgress::instance()->setTotalSteps(maxlines);
334
for (lin=0; lin<maxlines; ++lin)
339
for (col=0; col<maxcols; ++col)
342
TeBox box(x,y,x+resX,yu);
344
TePolygon polBox = polygonFromBox(box);
345
// check if the cell intersects the current polygon
346
if (TeIntersects(polBox,curPol))
350
if (db->spatialRelation(polTableName, TePOLYGONS,
351
(TePolygon*)&polBox, portal, TeINTERSECTS, theme->collectionTable()))
353
portal->fetchGeometry(curPol);
356
portal->freeResult();
360
TeCell cell(box,col,lin);
362
sprintf(celId,"C%02dL%02d",col,lin);
363
cell.objectId(string(celId));
367
row.push_back(cell.objectId());
368
row.push_back(Te2String(col));
369
row.push_back(Te2String(lin));
375
if (attTable.size() > 0) // if there is some attributes in this line
377
status = newLayer->saveAttributeTable(attTable);
379
status = newLayer->addCells(cells);
381
if(TeProgress::instance())
383
if (TeProgress::instance()->wasCancelled())
386
TeProgress::instance()->setProgress(lin);
391
if (TeProgress::instance())
392
TeProgress::instance()->reset();
398
db->deleteLayer(newLayer->id());
405
TeCellStatistics(TeTheme* themeOut, TeTable& newAttrTable, TeGroupingAttr& stat,
406
TeTheme* themeIn, TeDatabase* db)
409
TeGroupingAttr tempStat = stat;
410
string sqlResut = db->getSQLStatistics (tempStat);
413
TeGroupingAttr::iterator it = tempStat.begin();
414
while(it!= tempStat.end())
416
if(it->second != TeNOSTATISTIC)
424
if((!dbStat) || (sqlResut.empty()))
427
TeDatabasePortal* portal = db->getPortal();
430
//geom and collection tables from cell layer (cell)
431
string tableGeomOut = themeOut->layer()->tableName (TeCELLS);
433
if(themeOut->hasRestriction())
434
tableCollOut = themeOut->collectionTable();
436
//geom and collection tables from in layer (point or cell)
437
string tableGeomIn = themeIn->layer()->tableName (TePOINTS);
438
TeGeomRep geomRepIn = TePOINTS;
439
if(tableGeomIn.empty())
442
tableGeomIn = themeIn->layer()->tableName (TeCELLS);
446
if(themeIn->hasRestriction())
447
tableCollIn = themeIn->collectionTable();
450
string sql = " SELECT " + tableGeomOut + ".object_id, ";
452
sql += " FROM " + tableGeomOut +","+ tableGeomIn;
454
//for each point attr table
456
TeAttrTableVector vec = themeIn->attrTables();
457
for(unsigned int index=0; index<vec.size(); ++index)
459
if( (vec[index].tableType() != TeAttrStatic) &&
460
(vec[index].tableType() != TeAttrEvent) &&
461
(vec[index].tableType() != TeFixedGeomDynAttr)) //only to static attribute table
465
sql += ","+ vec[index].name();
468
if(!sqlWhere.empty())
470
sqlWhere += vec[index].name() +"."+ vec[index].linkName() +" = "+ tableGeomIn +".object_id ";
473
if(!tableCollIn.empty())
475
sql += ", "+ tableCollIn;
476
if(!sqlWhere.empty())
479
sqlWhere = tableGeomIn +".object_id = "+ tableCollIn +".c_object_id ";
481
if(!tableCollOut.empty())
483
sql += ", "+ tableCollOut;
484
if(!sqlWhere.empty())
487
sqlWhere += tableGeomOut +".object_id = "+ tableCollOut +".c_object_id ";
491
if(!sqlWhere.empty())
494
sqlWhere += db->getSQLBoxWhere (tableGeomOut, tableGeomIn, geomRepIn);
496
sql += " WHERE "+ sqlWhere;
497
sql += " GROUP BY "+ tableGeomOut +".object_id";
499
if(!portal->query(sql))
505
//Keep statistics in the tableAttrCell table
506
if(!TeKeepStatistics(newAttrTable, portal))
518
TeKeepStatistics(TeTable& tableAttrCell, TeDatabasePortal* portal)
521
TeAttributeList attr = portal->AttributeList();
523
//Mount the update sql from portal
524
string insert = "INSERT INTO "+ tableAttrCell.name() +" VALUES ( ";
525
while(portal->fetchRow())
528
for(unsigned int i=0; i<attr.size(); ++i)
533
string val = portal->getData(i);
534
if (attr[i].rep_.type_ == TeSTRING)
535
insert2 += "'"+ val +"'";
540
string result = insert + insert2 +" )";
542
if(!portal->getDatabase()->execute(result))
553
//////////////////////////////////////////////////////////////////////
555
// Fill Cell Auxiliary Funcions
557
/////////////////////////////////////////////////////////////////////
560
bool TeFillCellInitLoad (TeLayer* cell_layer, const string& cell_tablename, TeCellSet& cells)
562
if (!cell_layer) return false;
565
if (!cell_layer->getCells (cells)) return false;
567
// if dynamic table was not created, create it
569
if (!cell_layer->getAttrTablesByName(cell_tablename, table, TeFixedGeomDynAttr))
570
if (!TeCreateBasicDymanicCellTable (cell_layer, cell_tablename))
578
void TeFillCellInitSTO (const TeCell& cell, TeTimeInterval& t, TePropertyVector& result, TeSTElementSet& cellObjSet)
581
TeSTInstance cellObj;
582
cellObj.objectId (cell.objectId());
583
string uniqueId = cell.objectId();
584
cellObj.addUniqueId (uniqueId); // ANAP
585
uniqueId += t.getInitialDate() + t.getInitialTime();
586
uniqueId += t.getFinalDate() + t.getFinalTime() ;
587
cellObj.addUniqueId (uniqueId);
588
cellObj.timeInterval (t);
589
TePropertyVector::iterator itProp = result.begin();
590
while (itProp != result.end())
592
cellObj.addProperty (*itProp);
595
cellObjSet.insertSTInstance (cellObj);
602
TeCreateBasicDymanicCellTable (TeLayer* cell_layer, const string cell_tablename)
604
if (!cell_layer) return false;
606
TeAttribute attribute;
607
TeAttributeList attList;
608
TeAttributeList keyList;
611
attribute.rep_.name_ = "attr_id";
612
attribute.rep_.type_ = TeSTRING;
613
attribute.rep_.numChar_ = 48;
614
attribute.rep_.isPrimaryKey_ = true;
615
attList.push_back (attribute);
616
keyList.push_back(attribute);
619
attribute.rep_.name_ = "object_id";
620
attribute.rep_.type_ = TeSTRING;
621
attribute.rep_.numChar_ = 48;
622
attList.push_back ( attribute );
626
attribute.rep_.name_ = "initial_time";
627
attribute.rep_.type_ = TeDATETIME;
628
attribute.dateTimeFormat_ = "YYYYsMMsDDsHHsMMsSS";
629
attribute.dateChronon_ = TeSECOND;
630
attribute.rep_.numChar_ = 48;
631
attList.push_back ( attribute );
635
attribute.rep_.name_ = "final_time";
636
attribute.rep_.type_ = TeDATETIME;
637
attribute.dateTimeFormat_ = "YYYYsMMsDDsHHsMMsSS";
638
attribute.dateChronon_ = TeSECOND;
639
attribute.rep_.numChar_ = 48;
640
attList.push_back ( attribute );
642
// Create table and initialize attributes
644
TeTable cells_attTable (cell_tablename);
645
cells_attTable.setAttributeList(attList);
646
cells_attTable.setTableType(TeFixedGeomDynAttr);
647
cells_attTable.setLinkName("object_id");
648
cells_attTable.setUniqueName("attr_id");
649
cells_attTable.attInitialTime ("initial_time");
650
cells_attTable.attFinalTime ("final_time");
651
cells_attTable.attTimeUnit (TeSECOND);
653
if (!cell_layer->createAttributeTable(cells_attTable))
656
TeAttributeList attr;
657
cell_layer->database ()->getAttributeList (cell_tablename, attr);
664
//////////////////////////////////////////////////////////////////////
666
// Fill Cell Operations
668
/////////////////////////////////////////////////////////////////////
670
bool TeFillCellSpatialOperation (TeDatabase* db,
671
const string& input_layername,
673
const string& input_tablename,
674
const string& input_attrname,
676
const string& cell_layername,
677
const string& cell_tablename,
678
const string& output_columnName,
679
TeComputeAttrSpatialStrategy* operation)
682
if (!operation) return false;
683
if (!db) return false;
686
TeLayer* input_layer = new TeLayer (input_layername);
687
if (!db->loadLayer (input_layer))
689
cout << "\tLayer de entrada inexistente: " << input_layername << endl;
694
// Load output cells layer with geometry previously created
695
TeLayer* cell_layer = new TeLayer (cell_layername);
696
if (!db->loadLayer (cell_layer))
698
cout << "\tLayer de entrada inexistente: " << cell_layername << endl;
703
// Initialize cell set
705
if (!TeFillCellInitLoad (cell_layer, cell_tablename, cells)) return false;
708
// Initialize object set to store cell properties
709
TeSTElementSet cellObjSet (cell_layer);
713
TeTheme* theme = new TeTheme ("", input_layer);
714
vector<string> attrTableNames;
715
attrTableNames.push_back (input_tablename);
716
TeAttrTableVector atts;
717
if (!input_layer->getAttrTablesByName(attrTableNames, atts)) return false;
718
theme->setAttTables (atts);
721
TePropertyVector result;
722
TeCellSet::iterator cell_it = cells.begin();
723
while (cell_it != cells.end())
725
// Set restrictions on a theme and create stoset
726
theme->setSpatialRest((*cell_it).box(), rep);
727
result = operation->compute (theme, input_attrname, (*cell_it).box(), output_columnName);
728
TeFillCellInitSTO ((*cell_it), t, result, cellObjSet);
734
if (!TeUpdateDBFromSet(&cellObjSet, cell_tablename))
741
bool TeFillCellNonSpatialOperation (TeDatabase* db,
742
const string& input_layername,
744
const string& input_tablename,
745
const string& input_attrname,
747
const string& cell_layername,
748
const string& cell_tablename,
749
const string& output_columnName,
750
TeComputeAttrStrategy<TeSTElementSet::propertyIterator>* operation)
752
if (!db) return false;
755
TeLayer* input_layer = new TeLayer (input_layername);
756
if (!db->loadLayer (input_layer))
758
cout << "\tLayer de entrada inexistente: " << input_layername << endl;
763
// Load output cells layer with geometry previously created
764
TeLayer* cell_layer = new TeLayer (cell_layername);
765
if (!db->loadLayer (cell_layer))
767
cout << "\tLayer de entrada inexistente: " << cell_layername << endl;
772
// Initialize cell set
774
if (!TeFillCellInitLoad (cell_layer, cell_tablename, cells)) return false;
776
// Initialize object set to store cell properties
777
TeSTElementSet cellObjSet (cell_layer);
780
TeTheme* theme = new TeTheme ("", input_layer);
781
vector<string> attrTableNames;
782
attrTableNames.push_back (input_tablename);
783
TeAttrTableVector atts;
784
if (!input_layer->getAttrTablesByName(attrTableNames, atts)) return false;
785
theme->setAttTables (atts);
788
TePropertyVector result;
789
TeCellSet::iterator cell_it = cells.begin();
790
while (cell_it != cells.end())
792
// Set restrictions on a theme and create stoset
793
theme->setSpatialRest((*cell_it).box(), rep);
794
TeSTElementSet stos (theme);
795
vector<string> attrNames;
796
attrNames.push_back (input_attrname);
797
if (TeSTOSetBuildDB (&stos, false, false, attrNames))
798
result = operation->compute (stos.begin(input_attrname), stos.end(input_attrname), output_columnName); // if property not found, stos iterator will return zero to operation. To check this, have to be less general and use getProperty inside the compute method.
800
TeFillCellInitSTO ((*cell_it), t, result, cellObjSet);
806
if (!TeUpdateDBFromSet (&cellObjSet, cell_tablename))
815
bool TeFillCellNonSpatialRasterOperation (TeDatabase* db,
816
const string& input_raster_layername,
818
const string& cell_layername,
819
const string& cell_tablename,
820
const string& output_columnName,
821
TeComputeAttrStrategy<TeRaster::iteratorPoly>* operation)
823
if (!db) return false;
826
TeLayer* input_layer = new TeLayer (input_raster_layername);
827
if (!db->loadLayer (input_layer))
829
cout << "\tLayer de entrada inexistente: " << input_raster_layername << endl;
834
TeRaster* raster = input_layer->raster();
835
if (!raster) return false;
838
// Load output cells layer with geometry previously created
839
TeLayer* cell_layer = new TeLayer (cell_layername);
840
if (!db->loadLayer (cell_layer))
842
cout << "\tLayer de entrada inexistente: " << cell_layername << endl;
848
// Initialize cell set
850
if (!TeFillCellInitLoad (cell_layer, cell_tablename, cells)) return false;
853
// Initialize object set to store cell properties
854
TeSTElementSet cellObjSet (cell_layer);
858
TePropertyVector result;
859
TeCellSet::iterator cell_it = cells.begin();
860
while (cell_it != cells.end())
862
TePolygon p = TeBox2Polygon((*cell_it).box());
863
TeRaster::iteratorPoly rasterItBegin(raster);
864
rasterItBegin = raster->begin(p, TeBBoxPixelInters, 0);
865
TeRaster::iteratorPoly rasterItEnd(raster);
866
rasterItEnd = raster->end(p, TeBBoxPixelInters, 0);
868
result = operation->compute (rasterItBegin, rasterItEnd, output_columnName);
869
TeFillCellInitSTO ((*cell_it), t, result, cellObjSet);
874
if (!TeUpdateDBFromSet (&cellObjSet, cell_tablename))
881
bool TeFillCellAggregateOperation ( TeDatabase* db,
882
const string& input_layername,
883
const string& input_tablename,
885
const string& cell_layername,
886
const string& cell_tablename,
887
vector<string>& attrNames,
888
TeComputeAttrStrategy<TeSTElementSet::propertyIterator>* operation)
890
if (!db) return false;
894
TeLayer* input_layer = new TeLayer (input_layername);
895
if (!db->loadLayer (input_layer))
897
cout << "\tLayer de entrada inexistente: " << input_layername << endl;
903
// Load output cells layer with geometry previously created
904
TeLayer* cell_layer = new TeLayer (cell_layername);
906
if (!db->loadLayer (cell_layer))
908
cout << "\tLayer de entrada inexistente: " << cell_layername << endl;
913
// Initialize cell set
915
if (!TeFillCellInitLoad (cell_layer, cell_tablename, cells)) return false;
918
// Initialize object set to store cell properties
919
TeSTElementSet cellObjSet (cell_layer);
923
TeTheme* theme = new TeTheme ("", input_layer);
924
vector<string> attrTableNames;
925
attrTableNames.push_back (input_tablename);
926
TeAttrTableVector atts;
927
if (!input_layer->getAttrTablesByName(attrTableNames, atts)) return false;
928
theme->setAttTables (atts);
932
TeCellSet::iterator cell_it = cells.begin();
933
while (cell_it != cells.end())
935
TeSTInstance cellObj;
936
cellObj.objectId ((*cell_it).objectId());
937
string uniqueId = (*cell_it).objectId();
938
cellObj.addUniqueId (uniqueId);
939
uniqueId += t.getInitialDate() + t.getInitialTime();
940
uniqueId += t.getFinalDate() + t.getFinalTime() ;
941
cellObj.addUniqueId (uniqueId);
942
cellObj.timeInterval (t);
944
// Set restrictions on a theme and create stoset
945
theme->setSpatialRest((*cell_it).box(), TeCELLS); //????? TeWITHIN ok? ANAP
946
TeSTElementSet stos (theme);
947
TeSTOSetBuildDB (&stos, true, false, attrNames);
949
// Create stoset based on input layer
950
TePropertyVector result;
951
vector<string>::iterator attIt = attrNames.begin();
952
while (attIt != attrNames.end())
954
result = operation->compute (stos.begin(*attIt), stos.end(*attIt), (*attIt)); // if property not found, stos iterator will return zero to operation. To check this, have to be less general and use getProperty inside the compute method.
955
TePropertyVector::iterator itProp = result.begin();
956
while (itProp != result.end())
958
cellObj.addProperty (*itProp);
963
cellObjSet.insertSTInstance (cellObj);
969
if (!TeUpdateDBFromSet (&cellObjSet, cell_tablename))
980
bool TeFillCellConnectionOperation ( TeDatabase* db,
981
TeSTElementSet objects,
984
const string& input_attrName,
987
const string& cell_layername,
988
const string& cell_tablename,
989
const string& output_columnName,
992
TeComputeAttrStrategy<TeSTElementSet::propertyIterator>* operation,
993
double local_distance_factor,
994
double net_distance_factor,
995
double net_conn_factor,
999
if (!operation) return false;
1000
if (!net) return false;
1001
if (!db) return false;
1003
// Load output cells layer with geometry previously created
1005
TeLayer* cell_layer = new TeLayer (cell_layername);
1007
if (!db->loadLayer (cell_layer))
1009
cout << "\tLayer de entrada inexistente: " << cell_layername << endl;
1014
// Initialize cell set
1016
if (!TeFillCellInitLoad (cell_layer, cell_tablename, cells)) return false;
1019
// Initialize object set to store cell properties
1020
TeSTElementSet cellObjSet (cell_layer);
1024
TePropertyVector result;
1025
TeCellSet::iterator cell_it = cells.begin();
1026
while (cell_it != cells.end())
1028
TeSTInstance cellObj;
1029
cellObj.objectId ((*cell_it).objectId());
1030
string uniqueId = (*cell_it).objectId();
1031
cellObj.addUniqueId (uniqueId);
1032
uniqueId += t.getInitialDate() + t.getInitialTime();
1033
uniqueId += t.getFinalDate() + t.getFinalTime() ;
1034
cellObj.addUniqueId (uniqueId);
1035
cellObj.timeInterval (t);
1036
cellObjSet.insertSTInstance (cellObj);
1040
TeProxMatrixOpenNetworkStrategy2 sc_net (&cellObjSet, TeCELLS, &objects, rep, 0, TeMAXFLOAT, TeMAXFLOAT, net);
1041
// TeProxMatrixConnectionStrenghtStrategy sw(4, 0.0, false);
1042
TeProxMatrixInverseDistanceStrategy sw (local_distance_factor, net_distance_factor, net_conn_factor, mult_factor, false);
1043
TeProxMatrixNoSlicingStrategy ss_no;
1044
TeGeneralizedProxMatrix mat (&sc_net, &sw, &ss_no);
1046
// initialize object set to store cell properties
1047
TeSTElementSet cellObjSet2 (cell_layer);
1048
TeCellSet::iterator cell_it2 = cells.begin();
1049
while (cell_it2 != cells.end())
1051
TeSTElementSet neigh = mat.getSTENeighbours((*cell_it2).objectId());
1053
result = operation->compute (neigh.begin(input_attrName), neigh.end(input_attrName), output_columnName); // if property not found, stos iterator will return zero to operation. To check this, have to be less general and use getProperty inside the compute method.
1054
TeFillCellInitSTO ((*cell_it2), t, result, cellObjSet2);
1060
if (!TeUpdateDBFromSet (&cellObjSet2, cell_tablename))