newbiecihuy / timemap

Automatically exported from code.google.com/p/timemap
MIT License
0 stars 0 forks source link

Create data service architecture #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Right now, I have loader functions, parser functions, and potentially
preload and transform functions. It would be better to consolidate these
into data service classes with a predefined interface. You could then make
services to load more specific data sources, like Google spreadsheets, as
separate classes - these classes would encapsulate the preload and
transform functions that are now separate (though presumably they could
take custom pl/t functions as well).

This would simplify the dataset syntax in TimeMap.init(), which I've never
been totally happy with, to something like this:

{
  id: 'ds',
  title: 'My Dataset',
  theme: 'green'
  type: 'kml' // service class name, or optionally a service class
  options: {  // all info necessary for the service
    url: 'myfile.kml'
    // you could potentially set preload/transform functions here,
    // to override the default options; metaweb, e.g., needs transform
  }
}

This avoids the awkward "data" element, and trying to choose what goes in
"data" and what goes in the core dataset object.

Then you'd create the service and load the data:

var svcClass = TimeMap.services[ds.type];
var svc = new svcClass(ds.options);
svc.load(dataset, callback);

This setup would also make it simpler to load remote data on the fly, after
initialization, and much simpler to add new services to a service library.

Original issue reported on code.google.com by nick.rab...@gmail.com on 28 May 2009 at 4:30

GoogleCodeExporter commented 8 years ago

Original comment by nick.rab...@gmail.com on 28 May 2009 at 4:30

GoogleCodeExporter commented 8 years ago
Now added in trunk.

Original comment by nick.rab...@gmail.com on 14 Jul 2009 at 10:10