MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / AddCentroids

Method AddCentroids

Project.cpp:1104–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1102}
1103
1104void Project::AddCentroids()
1105{
1106 wxLogMessage("In Project::AddCentroids");
1107
1108 if (!table_int || main_data.records.size() == 0) return;
1109 GetCentroids();
1110 if (centroids.size() != num_records) return;
1111
1112 std::vector<double> x(num_records);
1113 std::vector<bool> x_undef(num_records, false);
1114 std::vector<double> y(num_records);
1115 std::vector<bool> y_undef(num_records, false);
1116 for (int i=0; i<num_records; i++) {
1117 if (centroids[i]->isNull()) {
1118 x_undef[i] = true;
1119 y_undef[i] = true;
1120 } else {
1121 x[i] = centroids[i]->center_o.x;
1122 y[i] = centroids[i]->center_o.y;
1123 }
1124 }
1125
1126 std::vector<SaveToTableEntry> data(2);
1127 data[0].d_val = &x;
1128 data[0].undefined = &x_undef;
1129 data[0].label = _("X-Coordinates");
1130 data[0].field_default = "COORD_X";
1131 data[0].type = GdaConst::double_type;
1132
1133 data[1].d_val = &y;
1134 data[1].undefined = &y_undef;
1135 data[1].label = _("Y-Coordinates");
1136 data[1].field_default = "COORD_Y";
1137 data[1].type = GdaConst::double_type;
1138
1139 SaveToTableDlg dlg(this, NULL, data, _("Add Centroids to Table"),
1140 wxDefaultPosition, wxSize(400,400));
1141 dlg.ShowModal();
1142}
1143
1144const std::vector<GdaPoint*>& Project::GetMeanCenters()
1145{

Callers 1

OnAddCentroidsMethod · 0.80

Calls 2

sizeMethod · 0.45
isNullMethod · 0.45

Tested by

no test coverage detected