Skip to content

Added output for the affiliated trajectories id #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/boliu/ClusterGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ public class ClusterGen {

private ArrayList<LineSegmentId> m_idArray = new ArrayList<ClusterGen.LineSegmentId>();
private ArrayList<CMDPoint> m_lineSegmentPointArray = new ArrayList<CMDPoint>();



// this variable is to return the clustered tracks' id
public ArrayList<ArrayList<Integer>> array_of_related_trajectories = new ArrayList<ArrayList<Integer>>();


//used for performing the DBSCAN algorithm
public static final int UNCLASSIFIED = -2;
public static final int NOISE = -1;
Expand Down Expand Up @@ -88,7 +91,6 @@ public ClusterGen(TraClusterDoc document) {
m_vector1 = new CMDPoint(m_document.m_nDimensions);
m_vector2 = new CMDPoint(m_document.m_nDimensions);
m_projectionPoint = new CMDPoint( m_document.m_nDimensions);


m_idArray.clear();
m_lineSegmentPointArray.clear();
Expand Down Expand Up @@ -196,7 +198,7 @@ private void findOptimalPartition(Trajectory pTrajectory) {

int nPoints = pTrajectory.getM_nPoints();
int startIndex = 0, length;
int fullPartitionMDLCost, partialPartitionMDLCost;
int fullPartitionMDLCost, partialPartitionMDLCost;

//add the start point of a trajectory
CMDPoint startP = pTrajectory.getM_pointArray().get(0);
Expand Down Expand Up @@ -546,6 +548,9 @@ boolean constructLineSegmentCluster() {
}

Set<Integer> trajectories = new HashSet<Integer>();



for(int i=0; i<m_currComponentId; i++) {
LineSegmentCluster clusterEntry = (m_lineSegmentClusters[i]);

Expand All @@ -558,6 +563,7 @@ boolean constructLineSegmentCluster() {
// DEBUG: count the number of trajectories that belong to clusters
for (int j = 0; j < (int)clusterEntry.trajectoryIdList.size(); j++)
trajectories.add(clusterEntry.trajectoryIdList.get(j));
array_of_related_trajectories.add(clusterEntry.trajectoryIdList);
//for(int j =0; j<((int)(m_lineSegmentClusters[i].trajectoryIdList.size())); j++)
// trajectories.add(m_lineSegmentClusters[i].trajectoryIdList.get(j));

Expand All @@ -581,7 +587,7 @@ boolean constructLineSegmentCluster() {
}
// DEBUG: compute the ratio of trajectories that belong to clusters
m_document.m_clusterRatio = (double)trajectories.size() / (double)m_document.m_nTrajectories;

m_document.array_related_trajectories = array_of_related_trajectories;
return true;
}

Expand Down Expand Up @@ -824,7 +830,6 @@ else if (j >= (int)clusterEntry.candidatePointList.size())
// ... END

int trajectoryId = m_idArray.get(lineSegmentId).trajectoryId;

// store the identifier of the trajectories that belong to this line segment cluster
if(!clusterEntry.trajectoryIdList.contains(trajectoryId))
//if (std::find(clusterEntry.trajectoryIdList.begin(), clusterEntry->trajectoryIdList.end(), trajectoryId) == clusterEntry.trajectoryIdList.end())
Expand Down
18 changes: 17 additions & 1 deletion src/boliu/TraClusterDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class TraClusterDoc {
public int m_nClusters;
public double m_clusterRatio;
public int m_maxNPoints;
public ArrayList<ArrayList<Integer>> array_related_trajectories;
public ArrayList<Trajectory> m_trajectoryList;
public ArrayList<Cluster> m_clusterList;

Expand All @@ -32,6 +33,8 @@ public TraClusterDoc() {
m_clusterRatio = 0.0;
m_trajectoryList = new ArrayList<Trajectory>();
m_clusterList = new ArrayList<Cluster>();
ClusterGen abc = new ClusterGen();

}

public class Parameter {
Expand Down Expand Up @@ -192,7 +195,20 @@ boolean onClusterGenerate(String clusterFileName, double epsParam, int minLnsPar
bw.write(x+" "+y+" ");
}
//System.out.println();
}
}

for(int i=0; i<array_related_trajectories.size(); i++)
{
bw.write("\nclusterID: "+ m_clusterList.get(i).getM_clusterId()+"\n");
System.out.print("\nclusterID: "+ m_clusterList.get(i).getM_clusterId()+"\n");
for(int j=0; j<array_related_trajectories.get(i).size(); j++)
{
bw.write(array_related_trajectories.get(i).get(j) + " ");
System.out.print(array_related_trajectories.get(i).get(j) + " ");

}

}

} catch (FileNotFoundException e) {
e.printStackTrace();
Expand Down