Skip to content

Commit

Permalink
GeoDa 1.4 code update
Browse files Browse the repository at this point in the history
  • Loading branch information
mmccann committed Apr 1, 2013
1 parent 6fcb6a2 commit a23a66d
Show file tree
Hide file tree
Showing 28 changed files with 2,288 additions and 2,099 deletions.
5 changes: 5 additions & 0 deletions DataViewer/DbfGridTableBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ void DbfColContainer::GetVec(std::vector<double>& vec, int time)
{
if (type != GeoDaConst::double_type &&
type != GeoDaConst::long64_type) return;
if (!vector_valid && IsRawDataAlloc()) CopyRawDataToVector();
if (vec.size() != size) vec.resize(size);
if (time < 0 || time >= time_steps) time = 0;
if (type == GeoDaConst::double_type) {
Expand All @@ -424,6 +425,7 @@ void DbfColContainer::GetVec(std::vector<wxInt64>& vec, int time)
{
if (type != GeoDaConst::double_type &&
type != GeoDaConst::long64_type) return;
if (!vector_valid && IsRawDataAlloc()) CopyRawDataToVector();
if (vec.size() != size) vec.resize(size);
if (time < 0 || time >= time_steps) time = 0;
if (type == GeoDaConst::long64_type) {
Expand Down Expand Up @@ -458,9 +460,11 @@ void DbfColContainer::GetVec(d_array_type& data)
{
if (type != GeoDaConst::double_type &&
type != GeoDaConst::long64_type) return;
if (!vector_valid && IsRawDataAlloc()) CopyRawDataToVector();
if (data.shape()[0] != time_steps || data.shape()[1] != size) {
data.resize(boost::extents[time_steps][size]);
}
if (!vector_valid && IsRawDataAlloc()) CopyRawDataToVector();
if (type == GeoDaConst::long64_type) {
if (vector_valid) {
for (int t=0; t<time_steps; t++) {
Expand Down Expand Up @@ -488,6 +492,7 @@ void DbfColContainer::GetVec(l_array_type& data)
{
if (type != GeoDaConst::double_type &&
type != GeoDaConst::long64_type) return;
if (!vector_valid && IsRawDataAlloc()) CopyRawDataToVector();
if (data.shape()[0] != time_steps || data.shape()[1] != size) {
data.resize(boost::extents[time_steps][size]);
}
Expand Down
7 changes: 6 additions & 1 deletion DialogTools/SHP2ASCDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ bool CreateASCBoundary(char* ishp, char* oasc, char* orasc, int field,
shp.read(hs, 2*GeoDaConst::ShpHeaderSize);
ShapeFileHdr hd(hs);

if (ShapeFileTypes::ShapeType(hd.FileShape()) == ShapeFileTypes::POLYGON)
if ((ShapeFileTypes::ShapeType(hd.FileShape())
== ShapeFileTypes::POLYGON) ||
(ShapeFileTypes::ShapeType(hd.FileShape())
== ShapeFileTypes::POLYGON_Z) ||
(ShapeFileTypes::ShapeType(hd.FileShape())
== ShapeFileTypes::POLYGON_M))
{
Box pBox;
for (long rec= 0; rec < n; ++rec)
Expand Down
3 changes: 2 additions & 1 deletion DialogTools/SaveToTableDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ void SaveToTableDlg::OnAddFieldButton( wxCommandEvent& event )
int col = dlg.GetColId();

GeoDaConst::FieldType type = grid_base->GetColType(col);
if (type != data[col].type && data[col].type == GeoDaConst::long64_type &&
if (type != data[obj_id].type &&
data[obj_id].type == GeoDaConst::long64_type &&
type != GeoDaConst::double_type) return;
// reinitialize all field lists, but set list corresponding to button
// to newly created field
Expand Down
15 changes: 14 additions & 1 deletion Explore/ConditionalMapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,20 @@ void ConditionalMapCanvas::ResizeSelectableShps(int virtual_scrn_w,
col_c = horiz_cat_data.categories[var_info[HOR_VAR].time].id_to_cat[i];
selectable_shps[i]->applyScaleTrans(st[row_c][col_c]);
}

if (selectable_shps_type == polygons) {
int proj_to_pnt_cnt = 0;
for (int i=0; i<num_obs; i++) {
if (((MyPolygon*) selectable_shps[i])->all_points_same) {
proj_to_pnt_cnt++;
}
}
double perc = proj_to_pnt_cnt*100;
perc /= (double) num_obs;
wxString s;
s << "ResizeSelectableShps: " << proj_to_pnt_cnt << "/" << num_obs;
s << ", " << perc << "% project to single point";
LOG_MSG(s);
}

BOOST_FOREACH( MyShape* shp, background_shps ) { delete shp; }
background_shps.clear();
Expand Down
2 changes: 1 addition & 1 deletion Explore/MapNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void MapNewCanvas::CreateAndUpdateCategories()
for (int i=0; i<num_obs; i++) {
if (P[i] <= 0) {
map_valid[t] = false;
map_error_message[t] = "Error: Base values contain "
map_error_message[t] = "Error: Base values contain"
" non-positive numbers. Cannot perform smoothing.";
continue;
}
Expand Down
36 changes: 32 additions & 4 deletions Generic/MyShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ void MyRectangle::paintSelf(wxDC& dc)
MyPolygon::MyPolygon(const MyPolygon& s)
: MyShape(s), //region(s.region),
n(s.n), pc(s.pc), points_o(s.points_o),
n_count(s.n_count)
n_count(s.n_count), all_points_same(s.all_points_same),
bb_ll_o(s.bb_ll_o), bb_ur_o(s.bb_ur_o)
{
points = new wxPoint[n];
for (int i=0; i<n; i++) {
Expand All @@ -731,7 +732,7 @@ MyPolygon::MyPolygon(const MyPolygon& s)
memory for the original set of points is also maintained internally and
will be deleted when the constructor is called. */
MyPolygon::MyPolygon(int n_s, wxRealPoint* points_o_s)
: n(n_s), pc(0), n_count(1)
: n(n_s), pc(0), n_count(1), all_points_same(false)
{
count = new int[1];
count[0] = n_s;
Expand All @@ -749,14 +750,22 @@ MyPolygon::MyPolygon(int n_s, wxRealPoint* points_o_s)
center_o = MyShapeAlgs::calculateMeanCenter(n, points_o);
center.x = (int) center_o.x;
center.y = (int) center_o.y;
bb_ll_o = center_o;
bb_ur_o = center_o;
for (int i=0; i<n; i++) {
if (points_o[i].x < bb_ll_o.x) bb_ll_o.x = points_o[i].x;
if (points_o[i].x > bb_ur_o.x) bb_ur_o.x = points_o[i].x;
if (points_o[i].y < bb_ll_o.y) bb_ll_o.y = points_o[i].y;
if (points_o[i].y > bb_ur_o.y) bb_ur_o.y = points_o[i].y;
}
//region = wxRegion(n, points);
}

/** This constructs a potentially multi-part polygon where each polygon
part might contain holes. Only a pointer to the original data is
kept, and this memory is not deleted in the destructor. */
MyPolygon::MyPolygon(Shapefile::PolygonContents* pc_s)
: n(0), points_o(0), pc(pc_s), points(0)
: n(0), points_o(0), pc(pc_s), points(0), all_points_same(false)
{
assert(pc);
count = new int[pc->num_parts];
Expand All @@ -772,6 +781,14 @@ MyPolygon::MyPolygon(Shapefile::PolygonContents* pc_s)
center_o = MyShapeAlgs::calculateMeanCenter(pc->points);
center.x = (int) center_o.x;
center.y = (int) center_o.y;
bb_ll_o = center_o;
bb_ur_o = center_o;
for (int i=0; i<n; i++) {
if (pc->points[i].x < bb_ll_o.x) bb_ll_o.x = pc->points[i].x;
if (pc->points[i].x > bb_ur_o.x) bb_ur_o.x = pc->points[i].x;
if (pc->points[i].y < bb_ll_o.y) bb_ll_o.y = pc->points[i].y;
if (pc->points[i].y > bb_ur_o.y) bb_ur_o.y = pc->points[i].y;
}
//region = wxRegion(n, points);
}

Expand All @@ -794,7 +811,11 @@ MyPolygon::~MyPolygon()

bool MyPolygon::pointWithin(const wxPoint& pt)
{
return MyShapeAlgs::pointInPolygon(pt, n, points);
if (all_points_same) {
return pt == center;
} else {
return MyShapeAlgs::pointInPolygon(pt, n, points);
}
//return region.Contains(pt) != wxOutRegion;
}

Expand All @@ -809,14 +830,21 @@ bool MyPolygon::regionIntersect(const wxRegion& r)
void MyPolygon::applyScaleTrans(const MyScaleTrans& A)
{
MyShape::applyScaleTrans(A); // apply affine transform to base class
all_points_same = true;
wxPoint tpt;
A.transform(bb_ll_o, &tpt);
if (tpt == center) A.transform(bb_ur_o, &tpt);
if (tpt == center) return;
if (points_o) {
for (int i=0; i<n; i++) {
A.transform(points_o[i], &(points[i]));
if (points[i] != center) all_points_same = false;
}
//region = wxRegion(n, points);
} else {
for (int i=0; i<n; i++) {
A.transform(pc->points[i], &(points[i]));
if (points[i] != center) all_points_same = false;
}
//region = wxRegion(n, points); // MMM: needs to support multi-part
}
Expand Down
8 changes: 7 additions & 1 deletion Generic/MyShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ class MyPolygon: public MyShape {
static wxRealPoint CalculateCentroid(int n, wxRealPoint* pts);
virtual void paintSelf(wxDC& dc);
public:
// All values in points array are the same. Can render render
// as a single point at points[0]
bool all_points_same;

wxPoint* points;
int n; // size of points array
int n_count; // size of count array
Expand All @@ -235,6 +239,8 @@ class MyPolygon: public MyShape {
// (pc == 0 && points_o !=0 ) || (pc != 0 && points_o ==0 )
Shapefile::PolygonContents* pc;
wxRealPoint* points_o;
wxRealPoint bb_ll_o; // bounding box lower left
wxRealPoint bb_ur_o; // bounding box upper right
//wxRegion region;
};

Expand Down Expand Up @@ -286,7 +292,7 @@ class MyRay: public MyShape {
public:
//wxPoint center; // inherited from MyShape
double degs_rot_cc_from_horiz;
int length; // lenght in pixels
int length; // length in pixels
protected:
//wxRealPoint center_o; // inherited from MyShape
};
Expand Down
2 changes: 1 addition & 1 deletion GeoDa-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>oGeoDa.icns</string>
<string>GeoDa.icns</string>
<key>CFBundleIdentifier</key>
<string>edu.asu.geodacenter.${PRODUCT_NAME:identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions GeoDa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ IMPLEMENT_APP(MyApp)
//ExitMainLoop(); // This will force the program to exit immediately
//}

#include "rc/oGeoDaIcon-16x16.xpm"
#include "rc/GeoDaIcon-16x16.xpm"

bool MyApp::OnInit(void)
{
Expand Down Expand Up @@ -989,7 +989,7 @@ wxFrame(NULL, -1, title, pos, size, style)
{
LOG_MSG("Entering MyFrame::MyFrame");

SetIcon(wxIcon(oGeoDaIcon_16x16_xpm));
SetIcon(wxIcon(GeoDaIcon_16x16_xpm));
SetMenuBar(wxXmlResource::Get()->LoadMenuBar("ID_SHARED_MAIN_MENU"));

wxToolBar* tb1;
Expand Down
2 changes: 1 addition & 1 deletion GeoDa.rc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ END

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "./rc/oGeoDa.ico"
IDI_ICON1 ICON "./rc/GeoDa.ico"

/////////////////////////////////////////////////////////////////////////////
//
Expand Down
10 changes: 5 additions & 5 deletions GeoDa.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\GeoDa.rc"
RelativePath=".\rc\GeoDa.ico"
>
</File>
<File
RelativePath=".\rc\oGeoDa.ico"
RelativePath=".\GeoDa.rc"
>
</File>
<File
Expand Down Expand Up @@ -277,15 +277,15 @@
>
</File>
<File
RelativePath=".\rc\menus.xrc"
RelativePath=".\rc\GeoDaIcon-16x16.xpm"
>
</File>
<File
RelativePath=".\rc\MyAppResources.cpp"
RelativePath=".\rc\menus.xrc"
>
</File>
<File
RelativePath=".\rc\oGeoDaIcon-16x16.xpm"
RelativePath=".\rc\MyAppResources.cpp"
>
</File>
<File
Expand Down
12 changes: 6 additions & 6 deletions GeoDa.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DD4E8B86164818A70014F1E7 /* ConnectivityHistView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD4E8B84164818A70014F1E7 /* ConnectivityHistView.cpp */; };
DD575B471231B73800AA0C11 /* GeoDaConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD575B461231B73800AA0C11 /* GeoDaConst.cpp */; };
DD579B6A160BDAFE00BF8D53 /* DorlingCartogram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD579B68160BDAFE00BF8D53 /* DorlingCartogram.cpp */; };
DD5A579716E53EC40047DBB1 /* GeoDa.icns in Resources */ = {isa = PBXBuildFile; fileRef = DD5A579616E53EC40047DBB1 /* GeoDa.icns */; };
DD5FA1DA0F320DD50055A0E5 /* ShapeFileHdr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD5FA1D90F320DD50055A0E5 /* ShapeFileHdr.cpp */; };
DD5FA2360F3231940055A0E5 /* shp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD5FA2350F3231940055A0E5 /* shp.cpp */; };
DD60546816A83EEF0004BF02 /* CatClassifManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD60546616A83EEF0004BF02 /* CatClassifManager.cpp */; };
Expand Down Expand Up @@ -87,7 +88,6 @@
DD7976F50F1D2D3100496A84 /* shp2cnt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD7976EB0F1D2D3100496A84 /* shp2cnt.cpp */; };
DD7976F60F1D2D3100496A84 /* shp2gwt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD7976EE0F1D2D3100496A84 /* shp2gwt.cpp */; };
DD79792A0F1E6CDB00496A84 /* MyAppResources.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD7979290F1E6CDB00496A84 /* MyAppResources.cpp */; };
DD7979460F1E8F3B00496A84 /* oGeoDa.icns in Resources */ = {isa = PBXBuildFile; fileRef = DD7979450F1E8F3B00496A84 /* oGeoDa.icns */; };
DD7B5E60112606F400B6D0B0 /* HighlightState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD7B5E5E112606F400B6D0B0 /* HighlightState.cpp */; };
DD7D5C711427F89B00DCFE5C /* LisaCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD7D5C6F1427F89B00DCFE5C /* LisaCoordinator.cpp */; };
DD7E91D3151A8F3A001AAC4C /* LisaScatterPlotView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DD7E91D2151A8F3A001AAC4C /* LisaScatterPlotView.cpp */; };
Expand Down Expand Up @@ -194,6 +194,7 @@
DD575B461231B73800AA0C11 /* GeoDaConst.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeoDaConst.cpp; sourceTree = "<group>"; };
DD579B68160BDAFE00BF8D53 /* DorlingCartogram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DorlingCartogram.cpp; sourceTree = "<group>"; };
DD579B69160BDAFE00BF8D53 /* DorlingCartogram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DorlingCartogram.h; sourceTree = "<group>"; };
DD5A579616E53EC40047DBB1 /* GeoDa.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = GeoDa.icns; sourceTree = "<group>"; };
DD5BD6E0125CCC07006E4E87 /* TestTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestTableView.h; path = Generic/TestTableView.h; sourceTree = "<group>"; };
DD5BD6E1125CCC07006E4E87 /* TestTableView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TestTableView.cpp; path = Generic/TestTableView.cpp; sourceTree = "<group>"; };
DD5FA1D80F320DD50055A0E5 /* ShapeFileHdr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeFileHdr.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -328,7 +329,6 @@
DD7976EE0F1D2D3100496A84 /* shp2gwt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shp2gwt.cpp; sourceTree = "<group>"; };
DD7976EF0F1D2D3100496A84 /* shp2gwt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shp2gwt.h; sourceTree = "<group>"; };
DD7979290F1E6CDB00496A84 /* MyAppResources.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyAppResources.cpp; sourceTree = "<group>"; };
DD7979450F1E8F3B00496A84 /* oGeoDa.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = oGeoDa.icns; sourceTree = "<group>"; };
DD7B5E5E112606F400B6D0B0 /* HighlightState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HighlightState.cpp; path = Generic/HighlightState.cpp; sourceTree = "<group>"; };
DD7B5E5F112606F400B6D0B0 /* HighlightState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HighlightState.h; path = Generic/HighlightState.h; sourceTree = "<group>"; };
DD7D5C6F1427F89B00DCFE5C /* LisaCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LisaCoordinator.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -465,8 +465,6 @@
DD7974650F1D1B0700496A84 = {
isa = PBXGroup;
children = (
DD64925A16DFF63400B3B0AB /* GeoDa.cpp */,
DD64925B16DFF63400B3B0AB /* GeoDa.h */,
DD972054150A6EE4000206F4 /* CmdLineUtils */,
DDDFB96D134B6B73005EF636 /* DataViewer */,
DDD4BBDD108521D30006F2D2 /* Generic */,
Expand All @@ -479,6 +477,8 @@
DD7976E10F1D2D3100496A84 /* ShapeOperations */,
DD64A2870F20FE06006B1E6D /* GeneralWxUtils.h */,
DD64A2860F20FE06006B1E6D /* GeneralWxUtils.cpp */,
DD64925B16DFF63400B3B0AB /* GeoDa.h */,
DD64925A16DFF63400B3B0AB /* GeoDa.cpp */,
DDAE6F4111A5A07C00BF5EEC /* GeoDaConst.h */,
DD575B461231B73800AA0C11 /* GeoDaConst.cpp */,
DDD13F040F2F8BE1009F7F13 /* GenGeomAlgs.h */,
Expand Down Expand Up @@ -675,14 +675,14 @@
DD7976070F1D2C5E00496A84 /* rc */ = {
isa = PBXGroup;
children = (
DD5A579616E53EC40047DBB1 /* GeoDa.icns */,
DDB056DA13554F080044C441 /* MyDataViewerAppRes.cpp */,
DDB056D813554EEC0044C441 /* data_viewer_dialogs.xrc */,
DD7976200F1D2C5E00496A84 /* dialogs.xrc */,
DD79761D0F1D2C5E00496A84 /* toolbar.xrc */,
DD7976270F1D2C5E00496A84 /* menus.xrc */,
DD563E061064237C0070781C /* release-notes.txt */,
DD7979290F1E6CDB00496A84 /* MyAppResources.cpp */,
DD7979450F1E8F3B00496A84 /* oGeoDa.icns */,
);
path = rc;
sourceTree = "<group>";
Expand Down Expand Up @@ -910,7 +910,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DD7979460F1E8F3B00496A84 /* oGeoDa.icns in Resources */,
DD5A579716E53EC40047DBB1 /* GeoDa.icns in Resources */,
DD6B74CC141ABC890026D223 /* menus.xrc in Resources */,
DD6B74CD141ABC8C0026D223 /* toolbar.xrc in Resources */,
DD6B74CF141ABCAD0026D223 /* data_viewer_dialogs.xrc in Resources */,
Expand Down
6 changes: 3 additions & 3 deletions GeoDaConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ class GeoDaConst {
static const int default_virtual_screen_marg_bottom = 20;
static const int shps_min_width = 100;
static const int shps_min_height = 100;
static const int shps_max_width = 6000;
static const int shps_max_height = 6000;
static const int shps_max_area = 10000000; // 10 million or 3162 squared
static const int shps_max_width = 12000;
static const int shps_max_height = 12000;
static const int shps_max_area = 50000000; // 50 million

static const wxColour selectable_outline_color; // black
static const wxColour selectable_fill_color; // forest green
Expand Down
Loading

0 comments on commit a23a66d

Please sign in to comment.