package me.itszooti.geojson.gson;

import java.lang.reflect.Type;

import me.itszooti.geojson.GeoFeature;
import me.itszooti.geojson.GeoObject;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

public class GeoFeatureSerializer implements JsonSerializer<GeoFeature> {

	@Override
	public JsonElement serialize(GeoFeature feature, Type type, JsonSerializationContext context) {
		// always an object
		JsonObject object = new JsonObject();
		
		// add id
		object.addProperty("id", feature.getId());
		
		// add geometry
		// force to go through GeoObject serializer
		object.add("geometry", context.serialize(feature.getGeometry(), GeoObject.class));
		
		// add properties
		
		
		return object;
	}

	
	
}

@@ -543,16 +543,57 @@
 ject();%0A
+%09%09object.addProperty(%22type%22, %22Feature%22);%0A
 %09%09%0A%09%09// 
@@ -821,16 +821,223 @@
 rties%0A%09%09
+JsonObject properties = new JsonObject();%0A%09%09object.add(%22properties%22, properties);%0A%09%09for (String name : feature.getPropertyNames()) %7B%0A%09%09%09properties.add(name, context.serialize(feature.getProperty(name)));%0A%09%09%7D
 %0A%09%09%0A%09%09re

Implement GeoFeature encoding